コード例 #1
0
ファイル: PlayerManager.cs プロジェクト: LoneXHuB/TchilaVirus
        public void UseAbbility(Pickable _ability)
        {
            switch (_ability.pickableType)
            {
            case PickableType.Magnesium:
                photonView.RPC("ActivateMagnet", RpcTarget.All);
                //Debug.Log("used magnesium!");
                break;

            case PickableType.Sulfur:
                photonView.RPC("ShootMultidirectional", RpcTarget.All);
                //Debug.Log("used Sulfur");
                break;

            case PickableType.Glucose:
                photonView.RPC("GoFast", RpcTarget.All);
                break;

            case PickableType.Proteine:
                photonView.RPC("Duplicate", RpcTarget.All);
                break;

            case PickableType.Vitamin:
                if (team == Team.Virus)
                {
                    photonView.RPC("MakeImmune", RpcTarget.All);
                }
                break;

            default:
                //Debug.Log("Uknown ability");
                break;
            }

            abilities.Remove(_ability);
        }
コード例 #2
0
 public void EmptySlot()
 {
     image.gameObject.SetActive(false);
     image.sprite = null;
     item         = null;
 }
コード例 #3
0
 public void ActivateSlot(Pickable _pickable)
 {
     item = _pickable;
     image.gameObject.SetActive(true);
     image.sprite = _pickable.sprite;
 }
コード例 #4
0
 public static void UpdateItemState(Pickable _pickable)
 {
     PickableTable.Remove(_pickable.Id);
     PickableTable.Add(_pickable.Id, _pickable.isPicked);
     PhotonNetwork.CurrentRoom.SetCustomProperties(PickableTable);
 }
コード例 #5
0
ファイル: GeneralAI.cs プロジェクト: LoneXHuB/TchilaVirus
        public void AnalyseEnvironement()
        {
            fleeVector   = Vector2.zero;
            stateMachine = AIState.OnDuty;
            if (radar == null)
            {
                return;
            }

            int _index = 0;

            foreach (Collider2D _detectedEntity in radar.detectedEntities)
            {
                if (_detectedEntity == null)
                {
                    continue;
                }

                PlayerManager    _player   = _detectedEntity.GetComponentInParent <PlayerManager>();
                Pickable         _pickable = _detectedEntity.GetComponent <Pickable>();
                ShieldController _shield   = _detectedEntity.GetComponent <ShieldController>();

                if (_pickable != null)
                {
                    bool _takePickable = true;
                    foundPickable = _pickable.transform;
                    if (stateMachine != AIState.Threatened && aiPlayerManager.abilities.Count < 2)
                    {
                        if (team == Team.Virus)
                        {
                            if (_pickable.pickableType == PickableType.Magnesium)
                            {
                                _takePickable = false;
                            }
                        }
                        else if (team == Team.White)
                        {
                            if (_pickable.pickableType == PickableType.Vitamin || _pickable.pickableType == PickableType.Proteine)
                            {
                                _takePickable = false;
                            }
                        }

                        if (_takePickable)
                        {
                            stateMachine = AIState.Curious;
                        }
                    }
                }
                if (_player != null)
                {
                    if (this.team != _player.team && this.team == Team.Virus)
                    {
                        fleeVector  += this.transform.position - _player.transform.position;
                        stateMachine = AIState.Threatened;

                        if (Vector2.Distance(this.transform.position, _player.transform.position) <= minAttackDistance)
                        {
                            try
                            {
                                Pickable _ability0 = aiPlayerManager.abilities[0];
                                Pickable _ability1 = aiPlayerManager.abilities[1];
                                aiPlayerManager.UseAbbility(_ability0);
                                aiPlayerManager.UseAbbility(_ability1);
                            }catch {}
                        }
                    }
                    else if (this.team != _player.team && this.team == Team.White)
                    {
                        enemyPosition = _player.transform;
                        stateMachine  = AIState.Chasing;
                    }
                }
                if (_shield != null)
                {
                    closeShieldPosition = _shield.transform;
                    if (this.team == Team.White && (target == closeShieldPosition))
                    {
                        FindRedShieldTarget();
                        //Debug.Log("too close to shield changing target !");
                    }
                    else if (this.team == Team.Virus && stateMachine == AIState.Threatened)
                    {
                        if (stateMachine == AIState.Threatened)
                        {
                            stateMachine = AIState.SeekingRefuge;
                            refugeShield = closeShieldPosition;
                            //Debug.Log("Virus is seeking refuge");
                        }
                        else
                        {
                            stateMachine = AIState.OnDuty;
                        }
                    }
                }

                radar.detectedEntities[_index] = null;
                _index++;
            }

            fleeTarget.position = this.transform.position + fleeVector.normalized * fleeDistance;
        }