示例#1
0
    private void Awake()
    {
        if (Pool != null && Pool != this)
        {
            Debug.LogWarning("La pool de atomos ya existe! Eliminando este objeto...", gameObject);
            Destroy(gameObject);
        }
        Pool = this;

        atoms = new List <GameObject>(initialAtoms);
        for (int i = 0; i < initialAtoms; i++)
        {
            GameObject atom = Instantiate(atomPrefab);
            atom.SetActive(false);
            atoms.Add(atom);
        }

        antiAtoms = new List <GameObject>();
        for (int i = 0; i < initialAnti; i++)
        {
            GameObject anti = Instantiate(antiAtomPrefab);
            anti.SetActive(false);
            antiAtoms.Add(anti);
        }
    }
示例#2
0
    public static AtomPool GetInstance()
    {
        if (instance == null)
        {
            instance = new AtomPool();
        }

        return(instance);
    }
示例#3
0
    void Start()
    {
        registeredAtomCreateCommands.Add(new EnemyAtomCreateCommand(AtomPool.GetInstance()));
        registeredAtomCreateCommands.Add(new FriendlyAtomCreateCommand(AtomPool.GetInstance()));

        Collider leftCollider  = leftWall.GetComponent <Collider>();
        Collider rightCollider = rightWall.GetComponent <Collider>();

        xLeftOfPlayfield  = leftWall.transform.position.x + leftCollider.bounds.extents.x + horizontalSafetyMargin;
        xRightOfPlayfield = rightWall.transform.position.x - rightCollider.bounds.extents.x - horizontalSafetyMargin;
    }
    void Update()
    {
        if (hasGameEnded && Input.GetKeyUp(KeyCode.R))
        {
            AtomPool.ResetAtomPool();
            SceneManager.LoadScene(SceneManager.GetActiveScene().name);
        }

        if (Input.GetKeyUp(KeyCode.Escape))
        {
            Application.Quit();
        }
    }
    void OnCollisionEnter(Collision collision)
    {
        if (isDestroyed)
        {
            return;
        }

        //If the atom we collided with is friendly, we do our stuff
        if (collision.gameObject.GetComponentInChildren <EnemyController>() == null)
        {
            isDestroyed = true;
            foreach (Docker docker in dockers)
            {
                docker.OnHitEnemy();
            }

            destroyAnimator.ResetTrigger("Reset");
            destroyAnimator.SetTrigger("Destroy");
            const int secondsTillDestruction = 1;
            AtomPool.GetInstance().DestroyEnemyAtom(transform.parent.gameObject, secondsTillDestruction);
        }
    }
 public EnemyAtomCreateCommand(AtomPool atomPool) : base(atomPool)
 {
 }
 public AtomCreateCommand(AtomPool atomPool)
 {
     this.atomPool = atomPool;
 }
示例#8
0
 public static void ResetAtomPool()
 {
     instance = null;
 }
示例#9
0
 public FriendlyAtomCreateCommand(AtomPool atomPool) : base(atomPool)
 {
 }