示例#1
0
    void FixedUpdate()
    {
        // update location
        obstacleLoc = transform.position;

        if (enemystrength < 0f)

        {
            //PRINCESS DEATH
            princessengaged = false;
            enemySpawn enemySpawn = GameObject.Find("Game Manager").GetComponent <enemySpawn> ();
            // don't spawn where i died
            enemySpawn.existingEnemies    -= 1;
            enemySpawn.princessdeathCount += 1;

            Movementscript Movementscript = GameObject.Find("Mino-man_Sprite").GetComponent <Movementscript>();
            Movementscript.pausemove = true;

            if (Movementscript.ragecount == 0)
            {
                Movementscript.ragecount = 1;
            }


            Destroy(gameObject);
        }
    }
示例#2
0
    void Update()
    {
        Movementscript Movementscript = GameObject.Find("Mino-man_Sprite").GetComponent <Movementscript>();

        curstricon = (int)Mathf.Floor(Movementscript.strength / 5) - 1;
        if (Movementscript.ragecount == 0)
        {
            GameObject.Find("Rageflame1_Icon(Clone)").GetComponent <Renderer> ().enabled = false;
            GameObject.Find("Rageflame2_Icon(Clone)").GetComponent <Renderer> ().enabled = false;
        }
        else
        {
            GameObject.Find("Rageflame1_Icon(Clone)").GetComponent <Renderer> ().enabled = true;
            GameObject.Find("Rageflame2_Icon(Clone)").GetComponent <Renderer> ().enabled = true;
        }
        Sprite strengthicon = gameObject.GetComponent <SpriteRenderer> ().sprite = striconstorage [curstricon];

        ingamesprite.sprite = strengthicon;
        //Debug.Log ("this happened");
    }
示例#3
0
    void FixedUpdate()
    {
        // update location
        obstacleLoc = transform.position;

        if (knightstrength < 0f)

        {
            // KNIGHT DEATH
            knightengaged = false;

            enemySpawn enemySpawn = GameObject.Find("Game Manager").GetComponent <enemySpawn> ();
            enemySpawn.existingEnemies -= 1;

            Movementscript Movementscript = GameObject.Find("Mino-man_Sprite").GetComponent <Movementscript>();
            Movementscript.pausemove = true;

            Destroy(gameObject);
        }
        // KNIGHT DIRECTION

        if (knightengaged)
        {
            // FACE MINO WHEN ENGAGED
            Vector3 Minoman = GameObject.Find("Mino-man_Sprite").transform.position;

            if (Minoman.x < transform.position.x)
            {
                transform.localEulerAngles = new Vector3(0, 0, -90);
                //Debug.Log ("West to face Minoman");
            }
            if (Minoman.x > transform.position.x)
            {
                transform.localEulerAngles = new Vector3(0, 0, 90);
                //Debug.Log ("East to face Minoman");
            }
            if (Minoman.y < transform.position.y)
            {
                transform.localEulerAngles = new Vector3(0, 0, 0);
                //Debug.Log ("South to face Minoman");
            }
            if (Minoman.y > transform.position.y)
            {
                transform.localEulerAngles = new Vector3(0, 0, -180);
                //Debug.Log ("North to face Minoman");
            }
        }

        else
        {
            // DECISION TIME FOR DIRECTION
            dirtimer -= Time.deltaTime;
            if (dirtimer <= 0)
            {
                dirtimer = 10f;
                // DECIDING DIRECTION
                knightpath();
                RaycastHit2D knightsight = Physics2D.Linecast(transform.position + (knightdir * knightsightStart), transform.position + (knightdir * knightsightLength));
                Debug.DrawLine(transform.position + (knightdir * knightsightStart), transform.position + (knightdir * knightsightLength), Color.blue, 1.5f);
            }
        }
    }
示例#4
0
    void ObstacleInstantiate()
    {
        // LIST OF BAD SPAWN POINTS
        List <Vector3> BadSpawnPoints = new List <Vector3> ();


        // PLACE TARGET POSITION IN LIST
        Movementscript Movementscript = GameObject.Find("Mino-man_Sprite").GetComponent <Movementscript>();

        BadSpawnPoints.Add(Movementscript.targetPos);

        // CREATE AN ARRAY FOR SURROUNDING COLLIDERS
        Collider2D[] TargetRadiusCast = Physics2D.OverlapCircleAll(Movementscript.targetPos, 1.5f);

        // PLACE SURROUNDING COLLIDERS IN LIST
        foreach (Collider2D col in TargetRadiusCast)
        {
            // CHECK FOR TAGS
            if (col.CompareTag("Tiles"))
            {
                // ADD TAG SPAWN POINTS TO BAD LIST
                BadSpawnPoints.Add(col.transform.position);
            }
        }

        // CREATE SPAWN POINT FOR OBSTACLE
        int     newspawnnumber = Random.Range(0, spawnplacement.Length);
        Vector3 AnySpawnPoint  = spawnplacement [newspawnnumber].position;


        // DISALLOW PRINCESS IF ONE IS IN SCENE?
        GameObject princessalive = GameObject.Find("Princess_Sprite(Clone)");

        if (princessalive)
        {
            // DISALLOW
            numprincess = 1;
        }
        else
        {
            // ALLOW
            numprincess = 0;
        }

        // CHOOSE RANDOM OBSTACLE
        ranspawnint = Random.Range(numprincess, 4);

        if (ranspawnint > 0)
        {
            InstantiatethisObstacle = KnightSprite;
        }
        else
        {
            InstantiatethisObstacle = PrincessSprite;
        }


        // SPAWN OBSTACLE
        if (!BadSpawnPoints.Contains(AnySpawnPoint))
        {
            Instantiate(InstantiatethisObstacle, AnySpawnPoint, Quaternion.identity);
            existingEnemies += 1;
        }
    }