Ejemplo n.º 1
0
    public static GameplayChannel GetInstance()
    {
        if (instance == null)
        {
            instance = new GameplayChannel();
        }

        return(instance);
    }
Ejemplo n.º 2
0
    // Update is called once per frame
    void Update()
    {
        bool previousResult = isHiding;

        isHiding = (numHidingSpots > 0);

        if (isHiding != previousResult)
        {
            GameplayChannel.GetInstance().SendPlayerHidingEvent(isHiding);
        }
    }
Ejemplo n.º 3
0
    // Update is called once per frame
    void Update()
    {
        fireTimer = Mathf.Max(0.0f, fireTimer - Time.deltaTime);

        // プレイヤーの情報が何も入ってない場合
        if (Player == null)
        {
            GameplayChannel.GetInstance().SendRequestPlayerEvent();
            return;
        }

        //更新処理 Update.
        _flowAI.Update(Time.deltaTime);

        time += Time.deltaTime;

        bool canSeePlayer = UpdatePlayerLastKnownPosition();

        _visionCone.CreateVisionConeMesh();

        // 敵を見ているかの判定
        //if (_visionCone.IsTargetInVisionCone(gameObject, Player))
        if (CanSeePlayer())
        {
            _isFound = true;

            //Debug.Log("Can see target! 主人公を見ています!");
        }
        else
        {
            _isFound = false;

            //Debug.Log("Cannot see target! 主人公を見ていません!");
        }


        //Any process...
        if (_isRot)
        {
            //head.transform.Rotate(new Vector3(0,0, 60f * Time.deltaTime));
            this.transform.Rotate(new Vector3(0, 60f * Time.deltaTime));
            head.transform.Rotate(new Vector3(0, (((-1) * 60f) * Time.deltaTime)));
        }
        if (_isBullet)
        {
            Shoot();
        }

        canSeePlayerPrevious = canSeePlayer;

        TFDebug.ClearMonitor("enemy");
        TFDebug.Write("enemy", "isRot:{0}\n", _isRot.ToString());
        TFDebug.Write("enemy", "isFound:{0}\n", _isFound.ToString());
    }
Ejemplo n.º 4
0
 private void OnTriggerEnter(Collider other)
 {
     Debug.Log("Win Triggered!");
     for (int i = 0; i < winTags.Count; ++i)
     {
         if (other.gameObject.CompareTag(winTags[i]))
         {
             GameplayChannel.GetInstance().SendWinEvent();
         }
     }
 }
Ejemplo n.º 5
0
    bool UpdatePlayerLastKnownPosition()
    {
        bool result = CanSeePlayer();

        if (result)
        {
            lastKnownPlayerPosition = Player.transform.position;
            GameplayChannel.GetInstance().SendPlayerSpottedEvent(lastKnownPlayerPosition);
        }

        return(result);
    }
Ejemplo n.º 6
0
    void SendDeathEventIfDead()
    {
        if (IsDead())
        {
            CharacterDeathInfo info;
            info.name          = gameObject.name;
            info.tag           = gameObject.tag;
            info.deathPosition = gameObject.transform.position;

            switch (deathEvent)
            {
            case DeathEvent.DeathEvent_Enemy:
                GameplayChannel.GetInstance().SendEnemyDeathEvent(info);
                break;

            case DeathEvent.DeathEvent_Player:
                GameplayChannel.GetInstance().SendPlayerDeathEvent(info);
                break;

            default:
                break;
            }
        }
    }
Ejemplo n.º 7
0
 private void Reset()
 {
     isHiding       = false;
     numHidingSpots = 0;
     GameplayChannel.GetInstance().SendPlayerHidingEvent(false);
 }
Ejemplo n.º 8
0
 // Use this for initialization
 void Start()
 {
     Reset();
     GameplayChannel.GetInstance().SendReplyPlayerEvent(gameObject);
 }
Ejemplo n.º 9
0
 void RequestPlayerEvent()
 {
     GameplayChannel.GetInstance().SendReplyPlayerEvent(gameObject); //私は主人公です。
 }
Ejemplo n.º 10
0
 void DeinitEvents()
 {
     GameplayChannel.GetInstance().RequestPlayerEvent -= RequestPlayerEvent;
 }
Ejemplo n.º 11
0
 void InitEvents()
 {
     GameplayChannel.GetInstance().ReplyPlayerEvent += ReplyPlayerEvent;
 }
Ejemplo n.º 12
0
 void DeinitEvents()
 {
     GameplayChannel.GetInstance().WinEvent         -= Win;
     GameplayChannel.GetInstance().PlayerDeathEvent -= Lose;
 }
Ejemplo n.º 13
0
 private void RegisterEvents()
 {
     GameplayChannel.GetInstance().ResetItemsEvent += ResetItem;
 }
Ejemplo n.º 14
0
 // アラート
 // Process Node Functions
 void AlertNodeFunction()
 {
     //Debug.Log("AlertNodeFunction");
     currentState = AIState.AIState_None;
     GameplayChannel.GetInstance().SendPlayerSpottedEvent(lastKnownPlayerPosition);
 }
Ejemplo n.º 15
0
    // Update is called once per frame
    void Update()
    {
        fireTimer = Mathf.Max(0.0f, fireTimer - Time.deltaTime);

        //Check if we know who the player is.
        if (player == null)
        {
            //Debug.Log("EnemyControl_Patrol::Update - No Player!");
            GameplayChannel.GetInstance().SendRequestPlayerEvent(); //主人公は誰ですか。
            return;                                                 // Skip this frame.
        }

        // 現のフレーム主人公おみましたか?
        bool canSeePlayer = UpdatePlayerLastKnownPosition();

        flowAI.Update(Time.deltaTime);

        switch (currentState)
        {
        case AIState.AIState_Patrol:
            Patrol();
            //Debug.Log(gameObject.name + "'s current state is PATROL.");
            break;

        case AIState.AIState_Chase:
            //Debug.Log(gameObject.name + "'s current state is CHASE.");
            Chase(canSeePlayer);
            break;

        case AIState.AIState_Explode:
            //Debug.Log(gameObject.name + "'s current state is EXPLODE.");
            エクスプロージョン();
            break;

        case AIState.AIState_Shoot:
            Shoot();
            break;

        default:
            // Do nothing.
            break;
        }

        if (canSeePlayer != canSeePlayerPrevious || previousState != currentState)
        {
            if (canSeePlayer)
            {
                visionCone.SetMaterial(canSeePlayerMaterial, true);
            }
            else
            {
                if (currentState == AIState.AIState_Chase)
                {
                    visionCone.SetMaterial(chaseCannotSeePlayerMaterial, true);
                }
                else
                {
                    visionCone.SetMaterial(patrolCannotSeePlayerMaterial, true);
                }
            }
        }

        // 更新
        // Update
        previousState        = currentState;
        canSeePlayerPrevious = canSeePlayer;
    }
Ejemplo n.º 16
0
 void DeinitEvents()
 {
     GameplayChannel.GetInstance().ReplyPlayerEvent   -= ReplyPlayerEvent;
     GameplayChannel.GetInstance().PlayerSpottedEvent -= PlayerSpottedEvent;
 }