예제 #1
0
 void OnPhotonSerializeView(PhotonStream stream, PhotonMessageInfo info)
 {
     if (stream.isWriting)
     {
         stream.SendNext(transform.position);
         stream.SendNext(transform.rotation);
         if (playerMotor != null)
         {
             stream.SendNext((Vector3)playerMotor.MoveVector);
             stream.SendNext(playerMotor.moveSpeed);
             stream.SendNext(playerMotor.RollSpeed);
             stream.SendNext((float)playerMotor.VerticalVelocity);
         }
         //stream.SendNext((bool)playerAnimator.LockAnimating);
         //stream.SendNext((int)playerAnimator.Mode);
         if (playerAnimator != null)
         {
             stream.SendNext((int)playerAnimator.MoveDirection);
             stream.SendNext((int)playerAnimator.State);
         }
         if (playerInfo != null)
         {
             stream.SendNext((int)playerInfo.GetVital((int)VitalName.Health).CurValue);
             //stream.SendNext((int)playerInfo.GetVital((int)VitalName.Mana).CurValue);
         }
     }
     else
     {
         correctPosition = (Vector3)stream.ReceiveNext();
         correctRotation = (Quaternion)stream.ReceiveNext();
         if (playerMotor != null)
         {
             playerMotor.MoveVector       = (Vector3)stream.ReceiveNext();
             playerMotor.moveSpeed        = (float)stream.ReceiveNext();
             playerMotor.RollSpeed        = (float)stream.ReceiveNext();
             playerMotor.VerticalVelocity = (float)stream.ReceiveNext();
         }
         //playerAnimator.LockAnimating = (bool)stream.ReceiveNext();
         //playerAnimator.Mode = (TP_Animator.CharacterMode)stream.ReceiveNext();
         if (playerAnimator != null)
         {
             playerAnimator.MoveDirection = (TP_Animator.Direction)stream.ReceiveNext();
             playerAnimator.State         = (TP_Animator.CharacterState)stream.ReceiveNext();
         }
         if (playerInfo != null)
         {
             playerInfo.GetVital((int)VitalName.Health).CurValue = (int)stream.ReceiveNext();
             //	playerInfo.GetVital((int)VitalName.Mana).CurValue = (int)stream.ReceiveNext();
         }
     }
 }
예제 #2
0
 void RangeAttack(TP_Info enemyInfo, int enemyID, int force, TP_Animator.HitWays hitWay)
 {
     if (IsAIButNotMasterClients())
     {
         return;
     }
     if ((int)enemyInfo.GetVital((int)VitalName.Health).CurValue > 0)
     {
         if (myPhotonView.isMine)
         {
             roomMenu.Hit(myPhotonView.viewID, enemyID, force, hitWay, HitSound.None);
         }
     }
 }
예제 #3
0
파일: AIScript.cs 프로젝트: PenpenLi/AOL
    void CheckSkillState()
    {
        if (playerInfo.GetVital((int)VitalName.Energy).CurValue == TP_Info.MAX_VITAL_VALUE_ENERGY)
        {
            skillState[0] = true;
        }
        else
        {
            skillState[0] = false;
        }

        for (int cnt = 1; cnt < 5; cnt++)
        {
            if (playerController.CheckSkillCDTime(cnt))
            {
                skillState[cnt] = true;
            }
            else
            {
                skillState[cnt] = false;
            }
        }
    }
예제 #4
0
    public void UpdateLocalState()
    {
        int kills     = InRoom_Menu.SP.localPlayer.properties.Kills;
        int bekilleds = InRoom_Menu.SP.localPlayer.properties.BeKills;
        int level     = InRoom_Menu.SP.localPlayer.properties.level;

        /*int getLS = InRoom_Menu.SP.localPlayer.properties.GetLightSource;
        *  int useLS = InRoom_Menu.SP.localPlayer.properties.UseLightSource;*/
        int money              = InRoom_Menu.SP.localPlayer.properties.Money;
        int HealthWaterNum     = InRoom_Menu.SP.localPlayer.properties.HealthWaterNum;
        int ManaHealthWaterNum = InRoom_Menu.SP.localPlayer.properties.ManaWaterNum;

        if (kills != 0)
        {
            LabelBase[(int)GameUILabel.Kill].text = kills.ToString();
        }
        if (level != 1)
        {
            LabelBase[(int)GameUILabel.Level].text = level.ToString();
        }
        if (bekilleds != 0)
        {
            LabelBase[(int)GameUILabel.Bekiled].text = bekilleds.ToString();
        }
        LabelBase[(int)GameUILabel.Money].text       = money.ToString();
        LabelBase[(int)GameUILabel.HealthWater].text = HealthWaterNum.ToString();
        LabelBase[(int)GameUILabel.ManaWater].text   = ManaHealthWaterNum.ToString();

        if (playerInfo != null)
        {
            int curHealth    = (int)playerInfo.GetVital((int)VitalName.Health).CurValue;
            int maxHealth    = (int)playerInfo.GetVital((int)VitalName.Health).MaxValue;
            int curMana      = (int)playerInfo.GetVital((int)VitalName.Mana).CurValue;
            int maxMana      = (int)playerInfo.GetVital((int)VitalName.Mana).MaxValue;
            int EnergyRate   = (int)((playerInfo.GetVital((int)VitalName.Energy).CurValue / 2000f) * 100);
            int GodPowerRate = (int)((playerInfo.GodPower / 100f) * 100);
            int curExp       = playerInfo.FreeExp;
            int maxExp       = playerInfo.ExpTpLevelUp;


            LabelBase[(int)GameUILabel.CurHealth].text    = curHealth.ToString();
            LabelBase[(int)GameUILabel.MaxHealth].text    = maxHealth.ToString();
            LabelBase[(int)GameUILabel.CurMana].text      = curMana.ToString();
            LabelBase[(int)GameUILabel.MaxMana].text      = maxMana.ToString();
            LabelBase[(int)GameUILabel.EnergyRate].text   = EnergyRate.ToString();
            LabelBase[(int)GameUILabel.GodPowerRate].text = GodPowerRate.ToString();
            LabelBase[(int)GameUILabel.CurExp].text       = curExp.ToString();
            LabelBase[(int)GameUILabel.MaxExp].text       = maxExp.ToString();

            vitalCDUI[0].fillAmount = (float)curHealth / maxHealth;
            vitalCDUI[1].fillAmount = (float)curMana / maxMana;
            vitalCDUI[2].fillAmount = (playerInfo.GetVital((int)VitalName.Energy).CurValue / 2000);
            vitalCDUI[3].fillAmount = (playerInfo.GodPower / 100);
            expUI.value             = curExp / (float)maxExp;
        }
    }
예제 #5
0
 public bool CheckMana(int skill)
 {
     if (playerInfo.GetVital((int)VitalName.Mana).CurValue > playerInfo.GetMagicSkill(skill - 1).Mana)
     {
         return(true);
     }
     else
     {
         return(false);
     }
 }
예제 #6
0
 void UpdateTeammateInfo()
 {
     foreach (GameObject info in TeammateInfoList)
     {
         if (info != null)
         {
             string  IDstr     = info.name;
             int     id        = Convert.ToInt32(IDstr);
             TP_Info plaInfo   = InRoom_Menu.SP.GetPlayerFromID(id).transform.GetComponent <TP_Info>();
             Vital   plaHealth = plaInfo.GetVital((int)VitalName.Health);
             int     maxHealth = plaHealth.MaxValue;
             float   curHealth = plaHealth.CurValue;
             info.GetComponentInChildren <UISlider>().value = curHealth / maxHealth;
             info.transform.FindChild("MaxHealth").GetComponent <UILabel>().text = maxHealth.ToString();
             info.transform.FindChild("CurHealth").GetComponent <UILabel>().text = ((int)curHealth).ToString();
         }
     }
 }
예제 #7
0
    void OnTriggerEnter(Collider enemy)
    {
        string enemyTag = enemy.tag;

        if (enemy.transform != parentTrans && enemyTag != "team1Light" && enemyTag != "team2Light")
        {
            {
                if (enemyTag == _enemyTeam || enemyTag == "monster")
                {
                    if (!isExploded)
                    {
                        CreateExplosion();
                    }
                    Debug.Log(enemy.name);
                    PhotonView enemyPV = enemy.GetComponent <PhotonView>();
                    if (enemyPV != null)
                    {
                        //hit
                        int     enemyID   = enemyPV.viewID;
                        TP_Info enemyInfo = enemy.GetComponent <TP_Info>();
                        if ((int)enemyInfo.GetVital((int)VitalName.Health).CurValue > 0)
                        {
                            if (playerView.isMine)
                            {
                                InRoom_Menu.SP.Hit(playerView.viewID, enemyID, _force, TP_Animator.HitWays.BeHit, HitSound.None);
                            }
                            //roomMenu.Hit(enemyPlayer,force);
                        }
                    }
                }
                else
                {
                    if (!isExploded)
                    {
                        CreateExplosion();
                    }
                }
            }
        }
    }
예제 #8
0
    void MeleeAttackCheck(float attDistance, float attAngle, int force, TP_Animator.HitWays hitWay)
    {
        if (IsAIButNotMasterClients())
        {
            return;
        }
        for (int cnt = 0; cnt < attackList.Count; cnt++)
        {
            Transform enemy = attackList[cnt];

            if (enemy == null)
            {
                attackList.Remove(enemy);
            }
            else
            {
                if (enemy != parentTrans)
                {
                    Vector3 targetDir = enemy.transform.position - parentTrans.position;

                    Vector3 dir   = targetDir.normalized;
                    float   angle = Vector3.Dot(dir, parentTrans.forward);
//					Debug.Log("Name:" + enemy.name +  " Dis:" + Vector3.Magnitude(targetDir) + "A:" + angle);

                    if (Vector3.Magnitude(targetDir) <= attDistance && angle > attAngle)
                    {
                        if (!tempList.Contains(enemy))
                        {
                            tempList.Add(enemy);
                        }
                    }
                }
            }
        }

        if (tempList.Count > 0)
        {
            HitSound sound = HitSound.None;
            if (playerInfo.Role == TP_Info.CharacterRole.Mars)
            {
                sound = HitSound.Sword1;
            }
            else if (playerInfo.Role == TP_Info.CharacterRole.DarkMan)
            {
                sound = HitSound.Sword2;
            }
            else if (playerInfo.Role == TP_Info.CharacterRole.Steropi)
            {
                sound = HitSound.Fist;
            }
            else if (playerInfo.Role == TP_Info.CharacterRole.Hyperion)
            {
                sound = HitSound.Slap;
            }
            for (int cnt = 0; cnt < tempList.Count; cnt++)
            {
                foreach (Transform enemy in tempList)
                {
                    //Transform enemy = attackList[cnt];
                    if (enemy == null)
                    {
                        tempList.Remove(enemy);
                    }
                    else
                    {
                        PhotonView enemyPV = enemy.GetComponent <PhotonView>();
                        if (enemyPV != null)
                        {
                            int     enemyID   = enemyPV.viewID;
                            TP_Info enemyInfo = enemy.GetComponent <TP_Info>();
                            if ((int)enemyInfo.GetVital((int)VitalName.Health).CurValue > 0)
                            {
                                Debug.Log(enemyInfo.gameObject.name + " got hit!");
                                if (myPhotonView.isMine)
                                {
                                    roomMenu.Hit(myPhotonView.viewID, enemyID, force, hitWay, sound);
                                }
                            }
                        }
                    }
                }
            }
        }
        tempList.Clear();
    }
예제 #9
0
파일: AIScript.cs 프로젝트: PenpenLi/AOL
    // Use this for initialization
    void Start()
    {
        myTransform = transform;
        rayDistance = 0.6f;
        backRayObj  = false;
        rightRayObj = false;
        leftRayObj  = false;

        wildHarnesses = GameObject.Find("GameScript").GetComponent <Game_Manager>().WildHarnesses;

        playerController = GetComponent <TP_Controller>();
        playerAnimator   = GetComponent <TP_Animator>();
        playerInfo       = GetComponent <TP_Info>();
        playerHealth     = playerInfo.GetVital((int)VitalName.Health);
        PhotonView playerView = GetComponent <PhotonView>();

        if (playerView.isMine)
        {
            _owner = true;
        }
        else
        {
            _owner = false;
        }
        aiRig.AI.WorkingMemory.SetItem("owner", _owner);

        aiRig.AI.WorkingMemory.SetItem("changePosTimer", 0);
        aiRig.AI.WorkingMemory.SetItem("DyingHealth", (int)(playerHealth.MaxValue * 0.1f));
        aiRig.AI.WorkingMemory.SetItem("wild", _wild);
        aiRig.AI.WorkingMemory.SetItem("T", 0);
        aiRig.AI.WorkingMemory.SetItem("isChangingPos", false);
        _task           = 0;
        _level          = 1;
        _speed          = playerInfo.GetAbility((int)(AbilityName.MoveSpeed)).CurValue;
        _canShopping    = true;
        _needShopping   = true;
        _atHome         = false;
        _atEnemyHome    = false;
        _hasEnemy       = false;
        _canChangeState = true;
        _canUseSkill    = true;

        aiRig.AI.WorkingMemory.SetItem("canUseSkill", _canUseSkill);
        aiRig.AI.WorkingMemory.SetItem("hasEnemy", _hasEnemy);
        aiRig.AI.WorkingMemory.SetItem("canShopping", _canShopping);
        aiRig.AI.WorkingMemory.SetItem("needShopping", _needShopping);
        aiRig.AI.WorkingMemory.SetItem("forwardSpeed", _speed);
        aiRig.AI.WorkingMemory.SetItem("canUseLS", true);
        aiRig.AI.WorkingMemory.SetItem("SkillTimer", 0);
        aiRig.AI.WorkingMemory.SetItem("LSTimer", 0);
        aiRig.AI.WorkingMemory.SetItem("atHome", _atHome);
        aiRig.AI.WorkingMemory.SetItem("atEnemy", _atEnemyHome);
        aiRig.AI.WorkingMemory.SetItem("ready", false);
        aiRig.AI.WorkingMemory.SetItem("TaskNum", _task);
        aiRig.AI.WorkingMemory.SetItem("attackTar", AttackTarget);
        _state  = playerAnimator.State.ToString();
        _attack = "";
        aiRig.AI.WorkingMemory.SetItem("state", _state);
        aiRig.AI.WorkingMemory.SetItem("attackWay", _attack);

        _wPNdiecrtion = Vector3.zero;
        aiRig.AI.WorkingMemory.SetItem("WPNdiecrtion", _wPNdiecrtion);
        //_state = TP_Animator.CharacterState.None;
        isResetWild = false;
        aiRig.AI.WorkingMemory.SetItem("reset", isResetWild);

        skillState = new bool[5];
    }
예제 #10
0
    // Update is called once per frame
    void Update()
    {
        if (Enemy != null)
        {
            aiRig.AI.WorkingMemory.SetItem("Enemy", Enemy);
        }
        if (type == MonsterType.monster)
        {
            if (BossScript != null)
            {
                Enemy = BossScript.aiRig.AI.WorkingMemory.GetItem <GameObject>("Enemy");
                aiRig.AI.WorkingMemory.SetItem("Enemy", Enemy);
                inLand = BossScript.inLand;
                aiRig.AI.WorkingMemory.SetItem("inLand", inLand);
            }
            else
            {
            }
        }
        else if (type == MonsterType.monsterBoss)
        {
            inLand = aiRig.AI.WorkingMemory.GetItem <bool>("inLand");
        }

        Recover = aiRig.AI.WorkingMemory.GetItem <bool>("recover");
        if (Recover)
        {
            playerInfo.GetVital((int)VitalName.Health).DamageValue = 0;
            myTransform.rotation = new Quaternion(myTransform.rotation.x, 0, myTransform.rotation.z, myTransform.rotation.w);
            foreach (MonsterScript ms in minions)
            {
                ms.playerInfo.GetVital((int)VitalName.Health).DamageValue = 0;
                ms.RotateToLand();
            }
        }
        playerHealth = playerInfo.GetVital((int)VitalName.Health);
        aiRig.AI.WorkingMemory.SetItem("health", playerHealth.CurValue);

        if (_speed != playerInfo.GetAbility((int)(AbilityName.MoveSpeed)).CurValue)
        {
            _speed = playerInfo.GetAbility((int)(AbilityName.MoveSpeed)).CurValue;
            aiRig.AI.WorkingMemory.SetItem("forwardSpeed", _speed);
        }


        if (_state == "InLand")
        {
            aiRig.AI.WorkingMemory.SetItem("state", "Idle");
        }

        _state = aiRig.AI.WorkingMemory.GetItem <string>("state");
        TP_Animator.CharacterState lastState = playerAnimator.State;

        if (playerAnimator.CanMove())
        {
            if (islocked)
            {
                islocked = false;
                aiRig.AI.WorkingMemory.SetItem("isLocked", islocked);
            }
        }
        else
        {
            if (!islocked)
            {
                islocked = true;
                aiRig.AI.WorkingMemory.SetItem("isLocked", islocked);
            }
        }

        if (_state == "runningForward")
        {
            if (playerAnimator.CanMove())
            {
                if (playerAnimator.MoveDirection != TP_Animator.Direction.Forward)
                {
                    playerAnimator.MoveDirection = TP_Animator.Direction.Forward;
                    playerAnimator.State         = TP_Animator.CharacterState.Running;
                }
            }
        }



        if (_state != playerAnimator.State.ToString())
        {
            /*if(_state == "Dead")
             *      playerAnimator.Die();*/
            if (lastState == TP_Animator.CharacterState.KnockingDown && !playerAnimator.LockAnimating)
            {
                playerAnimator.StandUp();
            }

            if (lastState != TP_Animator.CharacterState.Beinghit && lastState != TP_Animator.CharacterState.Dizzing && lastState != TP_Animator.CharacterState.Freeze && lastState != TP_Animator.CharacterState.Dead && lastState != TP_Animator.CharacterState.KnockingDown && lastState != TP_Animator.CharacterState.StandingUp && lastState != TP_Animator.CharacterState.Attacking001 && lastState != TP_Animator.CharacterState.Attacking002 && lastState != TP_Animator.CharacterState.Attacking003)
            {
                switch (_state)
                {
                case "Idle":
                    playerAnimator.MoveDirection = TP_Animator.Direction.Stationary;
                    playerAnimator.State         = TP_Animator.CharacterState.Idle;
                    break;
                }
            }
        }
        if (attackTimer == 0)
        {
            if (!playerAnimator.LockAttacking && !playerAnimator.LockAnimating)
            {
                _attack = aiRig.AI.WorkingMemory.GetItem <bool>("canAttack");
                if (_attack)
                {
                    if (lastState != TP_Animator.CharacterState.KnockingDown && lastState != TP_Animator.CharacterState.StandingUp && lastState != TP_Animator.CharacterState.EnergyStoring)
                    {
                        attackTimer = 1;
                        playerAnimator.LockAttacking = true;
                        playerAnimator.LockAnimating = true;
                        int way = 1;
                        if (type == MonsterType.monsterBoss)
                        {
                            way = (int)(Random.Range(1, 4 - 0.01f));
                        }
                        else if (type == MonsterType.monster)
                        {
                            way = (int)(Random.Range(1, 3 - 0.01f));
                        }
                        if (way == 1)
                        {
                            playerAnimator.Attack001();
                        }
                        else if (way == 2)
                        {
                            playerAnimator.Attack002();
                        }
                        else
                        {
                            playerAnimator.Attack003();
                        }
                    }
                }
            }
        }
    }