Пример #1
0
    public bool CheckOverlap(ColliderAABB other)
    {
        if (min.x > other.max.x)
        {
            return(false);
        }
        if (max.x < other.min.x)
        {
            return(false);
        }

        if (min.y > other.max.y)
        {
            return(false);
        }
        if (max.y < other.min.y)
        {
            return(false);
        }

        if (min.z > other.max.z)
        {
            return(false);
        }
        if (max.z < other.min.z)
        {
            return(false);
        }

        return(true);
    }
Пример #2
0
    void spawnPowerThree()
    {
        if (threes.Count > 0)
        {
            if (player.position.z - threes[0].transform.position.z > 25)
            {
                Destroy(threes[0]);
                threes.RemoveAt(0);
                Destroy(threesAABB[0]);
                threesAABB.RemoveAt(0);
            }
        }
        if (chunks.Count >= 3)
        {
            int    rng        = Random.Range(1, 10);
            string conversion = rng.ToString();

            Vector3 threePos = Vector3.zero;
            threePos = chunks[chunks.Count - 1].transform.Find("SpawnPoint" + conversion).position;

            float      moveUp   = Random.Range(0, 2);
            Vector3    hover    = new Vector3(0, moveUp * 2, 0);
            GameObject threeobj = Instantiate(PowerThree, threePos + hover, Quaternion.identity);
            threes.Add(threeobj);

            ColliderAABB threeAABB = threeobj.GetComponent <ColliderAABB>();
            threesAABB.Add(threeAABB);
        }
    }
Пример #3
0
    void spawnBlocks()
    {
        if (blocks.Count > 0)
        {
            if (player.position.z - blocks[0].transform.position.z > 25)
            {
                Destroy(blocks[0]);
                blocks.RemoveAt(0);
                Destroy(blocksAABB[0]);
                blocksAABB.RemoveAt(0);
            }
        }
        if (chunks.Count >= 3)
        {
            int    rng        = Random.Range(1, 10);
            string conversion = rng.ToString();

            Vector3 blockPos = Vector3.zero;

            blockPos = chunks[chunks.Count - 1].transform.Find("SpawnPoint" + conversion).position;

            int        moveUp   = Random.Range(0, 2);
            Vector3    hover    = new Vector3(0, moveUp * 2, 0);
            GameObject blockobj = Instantiate(Block, blockPos + hover, Quaternion.identity);
            blocks.Add(blockobj);

            ColliderAABB blockAABB = blockobj.GetComponent <ColliderAABB>();
            blocksAABB.Add(blockAABB);
        }
    }
Пример #4
0
    void spawnWalls()
    {
        if (walls.Count > 0)
        {
            if (player.position.z - walls[0].transform.position.z > 25)
            {
                Destroy(walls[0]);
                walls.RemoveAt(0);
                Destroy(wallsAABB[0]);
                wallsAABB.RemoveAt(0);
            }
        }
        if (chunks.Count >= 3)
        {
            int    rng        = Random.Range(1, 4) * 3 - 1;
            string conversion = rng.ToString();

            Vector3 wallPos = Vector3.zero;

            wallPos = chunks[chunks.Count - 1].transform.Find("SpawnPoint" + conversion).position;
            GameObject wallobj = Instantiate(Wall, wallPos, Quaternion.identity);
            walls.Add(wallobj);

            ColliderAABB wallAABB = wallobj.GetComponent <ColliderAABB>();
            wallsAABB.Add(wallAABB);
        }
    }
Пример #5
0
    void spawnEnemies()
    {
        if (enemies.Count > 0)
        {
            if (player.position.z - enemies[0].transform.position.z > 25)
            {
                Destroy(enemies[0]);
                enemies.RemoveAt(0);
                Destroy(enemiesAABB[0]);
                enemiesAABB.RemoveAt(0);
            }
        }
        if (chunks.Count >= 3)
        {
            int    rng        = Random.Range(1, 10);
            string conversion = rng.ToString();

            Vector3 enemyPos = Vector3.zero;

            enemyPos = chunks[chunks.Count - 1].transform.Find("SpawnPoint" + conversion).position;
            GameObject enemyobj = Instantiate(Enemy, enemyPos, Quaternion.identity);
            enemies.Add(enemyobj);

            ColliderAABB enemyAABB = enemyobj.GetComponent <ColliderAABB>();
            enemiesAABB.Add(enemyAABB);
        }
    }
Пример #6
0
    // Start is called before the first frame update
    void Start()
    {
        pBox = GameObject.Find("Player").GetComponent <ColliderAABB>();

        pickBox = GameObject.Find("PickAxe").GetComponent <ColliderAABB>();

        shieldBox = GameObject.Find("shield").GetComponent <ColliderAABB>();
    }
Пример #7
0
    // Start is called before the first frame update
    void Start()
    {
        ColliderAABB collider = GetComponent <ColliderAABB>();

        CollisionManager.walls.Add(collider);


        SpawnWallAt("Spawn1");
        SpawnWallAt("Spawn2");
        SpawnWallAt("Spawn3");
    }
Пример #8
0
    // Use this for initialization
    void Start()
    {
        //GameObject.Find("Main Camera").GetComponent<CollisionManager>().powerups.Add(GetComponent<ColliderAABB>());

        ColliderAABB collider = GetComponent <ColliderAABB>();

        collider.OnCollisionStart += StartCollide;
        collider.OnCollisionEnd   += EndCollide;

        CollisionManager.powerups.Add(collider);
    }
Пример #9
0
    void Start()
    {
        ColliderAABB collider = GetComponent <ColliderAABB>();

        collider.OnCollisionStart += StartCollide;
        collider.OnCollisionEnd   += EndCollide;

        CollisionManager.powerups.Add(collider);

        //decoupled very clean
    }
Пример #10
0
    public bool CheckOverlap(ColliderAABB other)
    {
        //X
        if (min.x > other.max.x)
        {
            return(false);
        }
        if (max.x < other.min.x)
        {
            return(false);
        }
        //Y
        if (min.y > other.max.y)
        {
            return(false);
        }
        if (max.y < other.min.y)
        {
            return(false);
        }
        //Z
        if (min.z > other.max.z)
        {
            return(false);
        }
        if (max.z < other.min.z)
        {
            return(false);
        }


        //float moveForword = other.maxz - min.z;

        //vector3 solution;

        //solution.z = mathf.Abs(moveForword) < mathf.Abs(moveBack) ? moveforward :moveback;

        //if (mathf.abs(soulution.z)> math.abs(solution.x) || mathf.abs(solution.z)> mathf.abs(solution.y))solution.z=0;

        // return solution;



        return(true);
    }
Пример #11
0
 public void SetCollisionWith(bool isColliding, ColliderAABB other)
 {
     if (isColliding)
     {
         if (!currentOverlaps.Contains(other))
         {
             currentOverlaps.Add(other);
             OnCollisionStart();// dispatch an event (collision start)
             print("collision begins");
         }
     }
     else
     {
         if (currentOverlaps.Contains(other))
         {
             currentOverlaps.Remove(other);
             OnCollisionEnd();// dispatch event (collison end)
             print("collision ends");
         }
     }
 }
Пример #12
0
 // Start is called before the first frame update
 void Start()
 {
     pBox = GameObject.Find("Player").GetComponent <ColliderAABB>();
 }
 void Start()
 {
     player = GameObject.Find("Cube").GetComponent <ColliderAABB>();
 }
Пример #14
0
    static public float mercyInvincibility = 0; //used to make sure the player doesn't get bodied by a bunch of stuff at once

    // Start is called before the first frame update
    void Start()
    {
        refAABB = GetComponent <ColliderAABB>();
    }
Пример #15
0
    void OnDestroy()
    {
        ColliderAABB collider = GetComponent <ColliderAABB>();

        CollisionManager.powerups.Remove(collider);
    }
Пример #16
0
 // Start is called before the first frame update
 void Start()
 {
     cb = GetComponent <ColliderAABB>();
     pr = GetComponent <PlayerRun>();
 }