コード例 #1
0
 // Use this for initialization
 void Start()
 {
     player          = GameObject.FindGameObjectWithTag("Player");
     onGround        = false;
     control         = true;
     canDash         = true;
     piloting        = false;
     direction       = 1;
     fuelSupply      = 100;
     horiAim         = "right";
     vertAim         = "";
     currentWep      = 0;
     rb.gravityScale = gravity;
     SetUpArrays();
     ResetCooldowns();
     SetCamMove();
     if (instance == null)
     {
         instance = this;
     }
     else
     {
         Destroy(this);
     }
 }
コード例 #2
0
    public void TakeDamage(float damage, float invulnPeriod)
    {
        if (!invulnerable)
        {
            health      -= damage;
            invulnerable = true;

            if (health <= 0f)
            {
                //put what you want on death to happen
                if (me.CompareTag("Player"))
                {
                    PlayerScript script = me.GetComponent <PlayerScript>();
                    script.Death();
                }
                if (me.CompareTag("Mech"))
                {
                    MechScript script = me.GetComponent <MechScript>();
                    script.Death();
                }
                //put tags of other items here
                if (me.CompareTag("Patroller"))
                {
                    PatrolEnemy script = me.GetComponent <PatrolEnemy>();
                    script.Death();
                }
                if (me.CompareTag("Flyer"))
                {
                    FlyingEnemy script = me.GetComponent <FlyingEnemy>();
                    script.Death();
                }
                if (me.CompareTag("Bomber"))
                {
                    BomberEnemy script = me.GetComponent <BomberEnemy>();
                    script.Death();
                }
                if (me.CompareTag("Boss"))
                {
                    BossEnemy script = me.GetComponent <BossEnemy>();
                    script.Death();
                }
            }
            else
            {
                Invoke("RemoveInvuln", invulnPeriod);
            }
        }
    }
コード例 #3
0
    //Name: TurnManagement
    //Parameters: N/A
    //Return value: N/A
    //Description: Coroutine for managing turns
    IEnumerator TurnManagement()
    {
        scriptG = Object[0].GetComponent <MechScript>();
        scriptD = Object[1].GetComponent <MechScript>();
        //yield return new WaitForSeconds(1.0f);
        foreach (Turn t in turns)
        {
            turnCounter.text = "Turn: " + t.turnNumber.ToString();
            switch (t.unit)
            {
            case 10:
                switch (t.actionType)
                {
                case 0:
                    scriptG.rbMech.position = new Vector3(t.xPos, 0.1f, t.zPos);;
                    scriptG.rbMech.rotation = Quaternion.Euler(0.0f, t.direction, 0.0f);
                    mHeath[0] = t.health;
                    yield return(new WaitForSeconds(1.0f));

                    break;

                case 1:
                    scriptG.shoot1 = true;
                    yield return(new WaitForSeconds(1.0f));

                    break;

                case 2:
                    scriptG.shoot2 = true;
                    yield return(new WaitForSeconds(1.0f));

                    break;

                case 3:
                    scriptG.newPos             = new Vector3(t.xPos, 0.0f, t.zPos);
                    scriptG.newRot.eulerAngles = new Vector3(0.0f, t.direction, 0.0f);
                    scriptG.move   = true;
                    scriptG.rotate = true;
                    yield return(new WaitUntil(() => (scriptG.move == false && scriptG.rotate == false)));

                    yield return(new WaitForSeconds(3.0f));

                    break;

                case 4:
                    gameStatus.text  = "Game Over";
                    scriptG.destroyM = true;
                    break;

                case 5:
                    mHeath[0] = t.health;
                    break;

                default:
                    break;
                }
                break;

            case 11:
                switch (t.actionType)
                {
                case 0:
                    mHeath[1] = t.health;
                    scriptD.rbMech.position = new Vector3(t.xPos, 0.1f, t.zPos);;
                    scriptD.rbMech.rotation = Quaternion.Euler(0.0f, t.direction, 0.0f);
                    break;

                case 1:
                    scriptD.shoot1 = true;
                    yield return(new WaitForSeconds(1.0f));

                    break;

                case 2:
                    scriptD.shoot2 = true;
                    yield return(new WaitForSeconds(1.0f));

                    break;

                case 3:
                    scriptD.newPos             = new Vector3(t.xPos, 0.0f, t.zPos);
                    scriptD.newRot.eulerAngles = new Vector3(0.0f, t.direction, 0.0f);
                    scriptD.move   = true;
                    scriptD.rotate = true;
                    yield return(new WaitUntil(() => (scriptD.move == false && scriptD.rotate == false)));

                    yield return(new WaitForSeconds(3.0f));

                    break;

                case 4:
                    gameStatus.text  = "Game Over";
                    scriptD.destroyM = true;
                    break;

                case 5:
                    mHeath[1] = t.health;
                    break;

                default:
                    break;
                }
                break;

            default:
                break;
            }
        }
        yield return(null);
    }