Пример #1
0
    public void OnHostFigureInfected(HostFigure hf)
    {
        if (hf.hostType == HostFigureType.Trump)
        {
            Destroy(player.GetComponent <Flingable> ());
        }
        else
        {
            score += 1;
            if (score <= powerMax)
            {
                ShowFloatingPowerText(hf.transform.position + Vector3.up * 2, score.ToString(), 0.8f, true, true);
            }

            if (score == powerMax && targetPointer == null)
            {
                foreach (GameObject floatingLabel in floatingLabels)
                {
                    Destroy(floatingLabel);
                }
                ShowFloatingText(player.transform.position + Vector3.up * 3, "MAX POWER, ATTACK!", 0.8f, false, true, 1, true);
                SpawnNewTarget();
            }
            else if (score == powerMax)
            {
                ShowFloatingText(player.transform.position + Vector3.up * 3, "MAX POWER, ATTACK!", 0.8f, false, true, 1);
            }

            score = Mathf.Min(score, powerMax);
        }

        //UpdateComboCounter (hf.transform.position + Vector3.up * 3f);
//        if (comboCounter % 5 == 0 && comboCounter > 0)
//            ShowFloatingText (player.transform.position + Vector3.up * 3, "AWESOME! +" + 5, 0.8f, false, true);
    }
    void InitialiseViruses()
    {
        for (int i = 0; i < 3; i++)
        {
            GameObject virus = virusList[Random.Range(0, virusList.Length)];

            Vector3 position = new Vector3(
                Random.Range(-sizeX * 0.5f, +sizeX * 0.5f),
                Random.Range(-sizeY * 0.5f, +sizeY * 0.5f),
                0
                );
            Vector3 rotation = new Vector3(0, 0, Random.Range(0f, 360f));

            Virus newVirus = Instantiate(virus,
                                         position, Quaternion.Euler(rotation)).GetComponent <Virus>();
            newVirus.GetComponent <Rigidbody2D>().AddForce(new Vector2(Random.value, Random.value).normalized
                                                           *Game.prefabs.speed, ForceMode2D.Impulse);

            Game.SceneObjects.viruses.Add(newVirus);
        }
        for (int i = 0; i < Game.SceneObjects.viruses.Count; i++)
        {
            Vector3 position = Game.SceneObjects.viruses[i].transform.position;
            if (position.x > sizeX + 20 || position.x < -sizeX - 20 || position.y > sizeY + 20 || position.y < -sizeY - 20)
            {
                Virus stray = Game.SceneObjects.viruses[i];
                Game.SceneObjects.viruses.Remove(stray);
                Destroy(stray.gameObject);
            }
        }
    }
Пример #3
0
    private void Infected()
    {
        // 感染候補者がいない
        if (m_candidate == null)
        {
            return;
        }

        // 感染能力を持っていない
        if (this.virus.NoneAbilityActor)
        {
            return;
        }

        // 感染者のウィルスのベースを確認
        Virus orginalVirus = this.virus.GetOriginal();

        // 感染源が存在しない
        if (orginalVirus == null)
        {
            Debug.Break();
        }

        // 感染させる
        m_candidate.Infected(orginalVirus.gameObject);

        // ビルに入れるようにする
        //NavMeshAgent navAgent = m_candidate.GetComponent<NavMeshAgent>();
        //navAgent.areaMask |= 1 << NavMesh.GetAreaFromName("Building");

        // ゾンビ状態でしか入れないエリアの開放
        NavMeshAgent navAgent = m_candidate.GetComponent <NavMeshAgent>();

        navAgent.areaMask |= 1 << NavMesh.GetAreaFromName("Infected");

        m_candidate = null;
    }
Пример #4
0
    // Update is called once per frame
    void Update()
    {
        var minions = FindObjectsOfType <Virus>();

        if (minions.Count() == 0)
        {
            return;
        }

        if (target == null || !target.isActiveAndEnabled || Vector3.Distance(target.transform.position, transform.position) > range)
        {
            target = minions.OrderBy(a => Vector3.Distance(a.transform.position, gameObject.transform.position)).First();
        }
        else if (weapon.IsReady())
        {
            weapon.Fire();
            towerIndicator.SetActive(true);
        }
        else
        {
            weapon.Aim(target.GetComponent <Combatant>());
            towerIndicator.SetActive(false);
        }
    }
Пример #5
0
 private void Placemat_OnPlacematEnter(GameObject placedObject)
 {
     currentVirus = placedObject.transform.root.GetComponent <Virus>();
     currentVirus.GetComponent <Rigidbody>().isKinematic = false;
 }
    public override void Excute(StateData data)
    {
        time += Time.deltaTime;
        // 感染後の待機時間
        if (time <= waitTime)
        {
            return;
        }

        // 移動コンポーネント
        Movement movement = data.movement;

        movement.SetSpeed(moveSpeed);
        // 拡張範囲の取得
        ExpansionControl expansion = data.virus.GetOriginal().GetComponent <ExpansionControl>();

        // 感染原(プレイヤ)
        Virus target    = data.virus.GetOriginal();
        Virus selfVirus = data.virus;

        //! ゲームの仕様上 ターゲットが見つからないことはない
        if (target.gameObject == null)
        {
            Debug.Break();
        }

        Vector3 playerVec /* = target.transform.position - hogePlayer*/;
        // 感染源の移動量
        float    x    = Input.GetAxisRaw("Horizontal2");
        float    z    = Input.GetAxisRaw("Vertical2");
        Vector3  vec  = new Vector3(x, 0, z);
        Movement move = target.GetComponent <Movement>();

        if (move == null)
        {
            Debug.Break();
        }
        //playerVec = vec.normalized * move.GetSpeed();

        // 拡張範囲を考慮した差
        Vector3 offset = vec;
        //offset.Normalize();
        float factor = 1.2f;

        offset     *= expansion.ExpansionArea * factor;
        followPoint = target.transform.position + offset * 1;

        Vector3 targetPos = new Vector3();

        // ウィルスコントロールをしているなら...
        if (target.GetComponent <PlayerController>().IsAction())
        {
            isUpdateDestination = true;

            //pathToFollowPoint = null;

            // 探索が終わっていない時 
            targetPos = followPoint;
            movement.SetPriority(50);
            movement.SetSpeed(moveSpeed);
            if (AIManager.infectedPathTemp == null)
            {
                movement.CalculatePath(targetPos, out AIManager.infectedPathTemp);
            }
        }
        else
        {
            followPoint = new Vector3();
            // 集合範囲内にいるか
            if ((target.transform.position - selfVirus.gameObject.transform.position).sqrMagnitude < expansion.ExpansionArea * expansion.ExpansionArea)
            {
                isUpdateDestination = false;
            }
            else
            {
                isUpdateDestination = true;
            }

            targetPos = target.gameObject.transform.position;
        }

        // 目的地の更新
        if (isUpdateDestination)
        {
            if (AIManager.infectedPathTemp != null)
            {
                movement.SetPath(AIManager.infectedPathTemp);
            }
            else
            {
                movement.SetDestination(targetPos);
            }
            //movement.SetIsStopped(false);
        }
        else
        {
            //movement.SetIsStopped(true);
            movement.ResetPath();
        }
    }