Yang.공부방

C,C++ 에서 함수포인터처럼 메서드를 안전하게 캡슐화하는 형식 (함수포인터와 다른점 : 개체지향적, 형식안전, 보안유지)

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
 
public class App : MonoBehaviour
{
    private float elapsedTime;
    private float attackAnimationLength = 0.733f;
    private bool attackStart = false;
    private bool isAttack = false;
    private int totalFrame = 22;
    private int attackFrame = 8;
 
    // Start is called before the first frame update
    void Start()
    {
        Debug.Log("앱이 실행되었습니다");
        this.attackStart = true;
    }
 
    // Update is called once per frame
    void Update()
    {
        if (this.attackStart == true)
        {
            this.elapsedTime += Time.deltaTime; //현재시간(누적)
            //현재프레임 = Total프레임 * 현재시간 / Total시간
            var fram = this.elapsedTime * this.totalFrame / this.attackAnimationLength;
            Debug.LogFormat("Fram : {0}", (int)fram);
            Debug.LogFormat("현재시간 : {0}"this.elapsedTime);
 
            if ((int)fram >= this.attackFrame)
            {
                //this.isAttack = true;
                Debug.LogFormat("<color=red>공격</color>");
                if (this.elapsedTime >= attackAnimationLength)
                {
                    elapsedTime = 0;
                    Debug.Log("애니메이션종료");
                    Debug.Log("기본애니메이션");
                    this.attackStart = false;
                }
            }
            
        }
    }
}
 
cs




공격 모선 끝나고 기본모션으로 전환하기 해야함