예제 #1
0
    private void OnCollisionEnter2D(Collision2D collision)
    {
        GameObject other = collision.gameObject;

        if (other.tag == "Wall")
        {
            this.bounceBack(other);
        }
        if (other.tag == "GatePickup")
        {
            LogicGateSpawn logicGateSpawn        = other.GetComponent <LogicGateSpawn>();
            Transform      logicGatePlayerSprite = Instantiate(logicGateSpawn.logicGatePlayerSprite, this.transform.position, this.transform.rotation);
            if (this.logicGatePlayerTransform)
            {
                Destroy(this.logicGatePlayerTransform.gameObject);
            }
            logicGatePlayerSprite.transform.parent = this.transform;
            this.logicGatePlayerTransform          = logicGatePlayerSprite;
            logicGateSpawn.destroy();
        }
        if (other.tag == "Socket")
        {
            Socket socket = other.GetComponent <Socket>();
            if (socket.overwriteable)
            {
                bool placedGate = socket.placeLogicGate(this.logicGatePlayerTransform);
                if (placedGate)
                {
                    this.logicGatePlayerTransform = null;
                }
            }
        }
    }
예제 #2
0
 void SpawnGate()
 {
     if (currentAndGates < maxAndGates)
     {
         Transform andGateSpawn = Instantiate(this.AndGate, this.getEnemySpawnPoint(), this.transform.rotation);
         this.currentAndGates++;
         LogicGateSpawn gateSpawn = andGateSpawn.GetComponent <LogicGateSpawn>();
         gateSpawn.Spawner = this;
     }
     if (currentOrGates < maxOrGates)
     {
         Transform ordGateSpawn = Instantiate(this.OrGate, this.getEnemySpawnPoint(), this.transform.rotation);
         this.currentOrGates++;
         LogicGateSpawn gateSpawn = ordGateSpawn.GetComponent <LogicGateSpawn>();
         gateSpawn.Spawner = this;
     }
     if (currentNotGates < maxNotGates)
     {
         Transform notGateSpawn = Instantiate(this.NotGate, this.getEnemySpawnPoint(), this.transform.rotation);
         this.currentNotGates++;
         LogicGateSpawn gateSpawn = notGateSpawn.GetComponent <LogicGateSpawn>();
         gateSpawn.Spawner = this;
     }
 }