예제 #1
0
파일: FireAI.cs 프로젝트: 741645596/batgame
    /// <summary>
    /// 获取飞行轨迹,及出生点
    /// </summary>
    /// <param name="fireai">飞行AI</param>
    /// <param name="FlyLine">返回飞行路线</param>
    /// <param name="BornPos">返回出生点</param>
    public static void GetFlyBorn(int fireai, ref List <Vector3> FlyLine, ref Vector3 BornPos)
    {
        Vector3      end  = Vector3.zero;
        LocationType t    = LocationType.Top;
        Life         deck = FireAI.GetHitDeck(fireai, ref end, ref t);

        CalcFlyData(deck, end, t, ref FlyLine, ref BornPos);
    }
예제 #2
0
    void FrieSoldiers()
    {
        List <int> firingRoleIDs = CmCarbon.GetFireSoldiers(m_timeElapse, 0f);

        for (int i = 0; i < firingRoleIDs.Count; i++)
        {
            int firingID = firingRoleIDs[i];

            if (m_WatingRoleIDs.Contains(firingID))
            {
                m_WatingRoleIDs.Remove(firingID);
                m_CountDownMap.Remove(firingID);
                mBattleIncomingWnd.DestroyEnemySoldier(firingID);
            }

            if (!m_FiringRoleMaps.ContainsKey(firingID))
            {
                SoldierInfo soldier = CmCarbon.GetSoldierInfo(LifeMCamp.ATTACK, firingID);
                m_FiringRoleMaps[firingID] = soldier;

                List <Vector3> FlyLine = new List <Vector3>();
                Vector3        BornPos = Vector3.zero;
                FireAI.GetFlyBorn(m_Soldier.m_FireAI, ref FlyLine, ref BornPos);

                m_FlyPostionMap[firingID] = FlyLine;
                PlayEnemyFlyHitPoint(BornPos);
            }
        }

        List <int> removeList = new List <int>();

        foreach (KeyValuePair <int, SoldierInfo> keyVal in m_FiringRoleMaps)
        {
            int         soldierID = keyVal.Key;
            SoldierInfo soldier   = keyVal.Value;

            List <Vector3> FlyLine = m_FlyPostionMap[soldierID];
            if (FlyLine != null && soldier != null)
            {
                if (SoldierFire.Fire(FlyLine, soldierID, soldier, false) == true)
                {
                    CmCarbon.SetBorn(soldierID);
                    removeList.Add(soldierID);
                }
            }
        }

        for (int i = 0; i < removeList.Count; i++)
        {
            int removeID = removeList[i];
            m_FiringRoleMaps.Remove(removeID);
        }
    }
예제 #3
0
    public void FireInstance()
    {
        Debug.Log("Instancing...");
        if (SpreadFlag == true)
        {
            Debug.Log("Instance method called");
            var new_fire = GameObject.Instantiate(fireball);

            //new_fire.transform.position = NextPositionCalculate(new_fire);
            new_fire.transform.position = nextArea;

            FireMeta.FireList.Add(new_fire);
            ChildFireList.Add(new_fire);
            FireAI child_fire_ai = new_fire.GetComponent <FireAI>();
            child_fire_ai.ParentFire = this.gameObject;
            //ネットワーク処理
            //NetworkServer.Spawn(new_fire);
        }
    }
예제 #4
0
    public void OnCellingFireInstance()
    {
        if (SpreadFlag)
        {
            var new_fire = GameObject.Instantiate(fireball);
            _rigidbody             = new_fire.GetComponent <Rigidbody>();
            _rigidbody.isKinematic = true;
            //_rigidbody.useGravity = false;

            //new_fire.transform.position = NextPositionCalculate(new_fire);
            new_fire.transform.position = nextArea;

            FireMeta.FireList.Add(new_fire);
            ChildFireList.Add(new_fire);
            FireAI child_fire_ai = new_fire.GetComponent <FireAI>();
            child_fire_ai.ParentFire = this.gameObject;
            //ネットワーク処理
            //NetworkServer.Spawn(new_fire);
        }
    }
예제 #5
0
    // Update is called once per frame
    void Update()
    {
        if (NearWallFrag == 1)
        {
            fire_ai                = this.GetComponent <FireAI>();
            fire_ai.NearWall       = 1;
            fire_rigid             = this.GetComponent <Rigidbody>();
            fire_rigid.isKinematic = true;
        }
        else
        {
            fire_rigid             = this.GetComponent <Rigidbody>();
            fire_rigid.isKinematic = false;
        }

        if (CellingFrag == 1)
        {
            fire_ai         = this.GetComponent <FireAI> ();
            fire_ai.Celling = 1;
        }
    }
예제 #6
0
    public void OnWallFireInstance()
    {
        if (SpreadFlag)
        {
            var new_fire = GameObject.Instantiate(fireball);
            //_rigidbody = new_fire.GetComponent<Rigidbody>();
            //_rigidbody.useGravity = false;
            //_rigidbody.isKinematic = true;

            //new_fire.transform.position = NextPositionCalculate(new_fire);
            var   now_pos = this.transform.position;
            float x       = now_pos.x + Random.Range(-0.1f, 0.1f);
            float y       = nextArea.y + Random.Range(0.2f, 0.4f);
            float z       = now_pos.z + Random.Range(-0.1f, 0.1f);
            new_fire.transform.position = new Vector3(x, y, z);

            FireMeta.FireList.Add(new_fire);
            ChildFireList.Add(new_fire);
            FireAI child_fire_ai = new_fire.GetComponent <FireAI>();
            child_fire_ai.ParentFire = this.gameObject;
            //ネットワーク処理
            //NetworkServer.Spawn(new_fire);
        }
    }
예제 #7
0
    // Update is called once per frame
    void Update()
    {
        for (j = 0; j < WetObject.Count; j++)
        {
            if (WetObject[j] == null)
            {
                WetObject.RemoveAt(j);
            }
        }

        for (i = 0; i < FireList.Count; i++)
        {
            fire_AI = FireList[i].GetComponent <FireAI>();
            if (fire_AI.DestroyedFlag)
            {
                Destroy(FireList[i]);
                FireList.RemoveAt(i);
            }
        }

        for (i = 0; i < FireList.Count; i++)
        {
            fire_AI  = FireList[i].GetComponent <FireAI>();
            fire_pos = FireList[i].transform.position;

            fire_AI.SpreadFlag = false;
            Debug.Log("Ready to No." + i);

            k = 0;

            if (WetObject.Count >= 1)
            {
                do
                {
                    TooBad = 0;

                    Debug.Log("next area serched at " + (k + 1) + " times...");

                    next = RandomNextVector(fire_pos);

                    for (j = 0; j < WetObject.Count; j++)
                    {
                        if (Vector3.Distance(next, WetObject[j].transform.position) <= limit_distance)
                        {
                            TooBad++;
                        }
                    }

                    k++;

                    if (k >= 50)
                    {
                        Debug.Log("next area can't generated!");
                    }
                } while (TooBad > 0 && k < 50);
            }
            else
            {
                next = RandomNextVector(fire_pos);
            }

            if (k < 50 && FireList.Count <= 10)
            {
                fire_AI.SpreadFlag = true;
                fire_AI.nextArea   = next;
                Debug.Log("No." + i + " is able to Spread");
            }
            else
            {
                Debug.Log("No." + i + " can't Spread...");
                //fire_AI.SpreadFlag = false;
                fire_AI.nextArea = CurrentVector(fire_pos);
            }
        }

        //x++;                          //デバッグ用
        //if (x >= 5) {
        //    Debug.Log("Hello!");
        //    x = 0;
        //}
    }
 // Use this for initialization
 void Start()
 {
     game_obj = this.gameObject;
     fire_ai  = game_obj.GetComponent <FireAI>();
 }
예제 #9
0
    // Update is called once per frame
    void Update()
    {
        //distancefromPlayer = Vector3.Distance(transform.position, target.transform.position);
        //Debug.Log(distancefromPlayer);

        if (timeuntilleavingPuddle >= 20.0f)
        {
            GameObject lavapuddleClone = Instantiate(lavaPuddle, lavapuddlePlacement.position, transform.rotation);
            Transform  puddleSpot      = lavapuddleClone.transform;
            lavapuddleClone.transform.localScale += new Vector3(2.0f, 0.0f, 2.0f);
            lavapuddleClone.transform.parent      = null;
            lavapuddleClone.transform.SetParent(puddleSpot);
            timeuntilleavingPuddle = 0.0f;
        }

        switch (fAI)
        {
        case FireAI.Run:
            nmAgent.speed     = speed;
            nmAgent.isStopped = false;
            nmAgent.SetDestination(target.transform.position);
            distancefromPlayer = Vector3.Distance(transform.position, target.transform.position);
            if (distancefromPlayer <= attackRange)
            {
                setState(FireAI.attack1);
            }
            else
            {
                timeuntilleavingPuddle += 0.01f;
                //Debug.Log(timeuntilleavingPuddle);
            }
            if (health <= 0.0f)
            {
                setState(FireAI.death2);
            }
            break;

        case FireAI.attack1:
            nmAgent.isStopped = true;
            nmAgent.speed     = 0;
            ++temperature;
            Debug.Log(temperature);
            if (temperature >= 400f)
            {
                Destroy(gameObject);
                distancefromPlayer = Vector3.Distance(transform.position, target.transform.position);
                if (distancefromPlayer <= 5f)
                {
                    target.GetComponent <PlayerHealth>().changeHealth(enemyDamage);
                }
            }
            distancefromPlayer = Vector3.Distance(transform.position, target.transform.position);
            if (distancefromPlayer > attackRange)
            {
                setState(FireAI.Run);
            }
            break;

        case FireAI.attack2:
            break;

        case FireAI.gethit:
            if (target.GetComponent <AR>())
            {
                health -= target.GetComponent <AR>().weaponDamage;
                if (health <= 0.0f)
                {
                    fAI = FireAI.death2;
                }
                break;
            }
            if (target.GetComponent <smg>())
            {
                health -= target.GetComponent <smg>().weaponDamage;
                if (health <= 0.0f)
                {
                    fAI = FireAI.death2;
                }
                break;
            }
            if (target.GetComponent <RocketLauncher>())
            {
                health -= target.GetComponent <RocketLauncher>().weaponDamage;
                if (health <= 0.0f)
                {
                    fAI = FireAI.death2;
                }
                break;
            }
            if (target.GetComponent <GrenadeLauncher>())
            {
                health -= target.GetComponent <GrenadeLauncher>().weaponDamage;
                if (health <= 0.0f)
                {
                    fAI = FireAI.death2;
                }
                break;
            }
            if (target.GetComponent <pistol>())
            {
                health -= target.GetComponent <pistol>().weaponDamage;
                if (health <= 0.0f)
                {
                    fAI = FireAI.death2;
                }
                break;
            }
            if (target.GetComponent <SniperRifle>())
            {
                health -= target.GetComponent <SniperRifle>().weaponDamage;
                if (health <= 0.0f)
                {
                    fAI = FireAI.death2;
                }
                break;
            }
            if (target.GetComponent <shotgun>())
            {
                health -= target.GetComponent <shotgun>().weaponDamage;
                if (health <= 0.0f)
                {
                    fAI = FireAI.death2;
                }
                break;
            }
            if (target.GetComponent <EnergyHammer>())
            {
                health -= target.GetComponent <EnergyHammer>().weaponDamage;
                if (health <= 0.0f)
                {
                    fAI = FireAI.death2;
                }
            }
            break;

        case FireAI.death1:
            break;

        case FireAI.death2:
            Destroy(gameObject);
            target.GetComponent <PlayerScore>().playerScore += target.GetComponent <PlayerScore>().pointsperKill;
            int randomnumber = Random.Range(0, 100);
            if (randomnumber % 4 == 0)
            {
                int randompowerup = Random.Range(0, 2);
                Instantiate(target.GetComponent <Arsenal>().powerups[randompowerup], transform.position, transform.rotation);
            }
            break;

        default:
            break;
        }
    }
예제 #10
0
 public void setState(FireAI state)
 {
     fAI = state;
 }