void KeyCodF5()//SelfDestroy
 {
     if (Input.GetKeyUp(KeyCode.F5))
     {
         if (botController != null)
         {
             botController.ChangeState(1);//"Destroy"
         }
     }
 }
Exemple #2
0
    private void Update()
    {
        if (Input.GetMouseButton(0))
        {
            foreach (WeaponController w in stats.weapons)
            {
                w.Fire();
            }
        }

        if (Input.GetMouseButtonDown(1))
        {
            Ray        ray = new Ray(cam.transform.position, cam.transform.forward);
            RaycastHit hit;
            if (Physics.SphereCast(ray, hitInfo: out hit, maxDistance: 100f, radius: .15f, layerMask: LayerMask.GetMask("Default", "AI")))
            {
                if (hit.transform.gameObject.tag == "Bot")
                {
                    hit.transform.GetComponent <BotController>().ChangeState(BotController.ControlState.Player);
                    botController.ChangeState(BotController.ControlState.AI);
                }
            }
        }
        //if (weaponTransform) {
        //    var targetPosition = cam.transform.position + cam.transform.forward;
        //    targetPosition = new Vector3(weaponTransform.position.x,
        //                                targetPosition.y,
        //                                weaponTransform.position.z);
        //    weaponTransform.LookAt(targetPosition);
        //    //weaponTransform.Rotate(new Vector3( 0f, 90f, 0f));
        //}
        //if (weaponTransform) weaponTransform.LookAt(cam.transform.position + cam.transform.forward, Vector3.up);
    }
    void GetNextBot()
    {
        int tmpIndex = arrayBotController.Count;

        while (tmpIndex > 0)
        {
            tmpIndex--;

            if (indexBot > arrayBotController.Count - 1)
            {
                indexBot = 0;
            }

            if (playerState == PlayerState.FollowBot)
            {
                botController = arrayBotController[indexBot];
                botController.ChangeState(5);//"PlayerFollow"
                return;
            }

            indexBot++;
        }

        {
            ChangePlayerState(1);//Spectator
        }
    }