private Vector3 getVelocityDueToAlgae()
    {
        if (headingHome)
        {
            return(Vector3.zero);
        }

        cluster.RemoveWhere(x => x == null);
        if (cluster.Count == 0)
        {
            return(Vector3.zero);
        }

        AlgaeController nearest     = null;
        float           minDistance = float.PositiveInfinity;

        foreach (AlgaeController algae in cluster)
        {
            float mag = (algae.transform.position - transform.position).magnitude;
            if (mag < minDistance)
            {
                minDistance = mag;
                nearest     = algae;
            }
        }
        Vector3 delta = Vector3.zero;

        delta = nearest.transform.position - transform.position;

        return(delta.normalized);
    }
Exemple #2
0
    public void HandleAlgaeTile(GameObject obj, int x, int y, Direction dir)
    {
        AlgaeController ac = obj.GetComponent <AlgaeController>();

        ac.position  = new Position(x, y);
        ac.direction = dir;
    }
Exemple #3
0
 void OnTriggerStay(Collider other)
 {
     //Debug.Log(other.gameObject.name);
     if (other.CompareTag("TAG_ALGAE"))
     {
         AlgaeController algae = other.gameObject.GetComponent <AlgaeController>();
         algae.lifeStrength -= killingPower;
     }
 }
Exemple #4
0
    public void HandlePlayerShot(Collider2D col)
    {
        if (col.transform.tag == "Algae")
        {
            AlgaeController ac = col.gameObject.GetComponent <AlgaeController>();
            bc.objectBoard[ac.position.x][ac.position.y] = TileEnum.None;
        }

        am.explosion.Play();
        Debug.Log("TORPEDO TRIGGERED WITH " + col.transform.name);
        if (col.transform.tag != "Ground" && col.transform.tag != "Goal" &&
            col.transform.tag != "Player")
        {
            Destroy(col.transform.gameObject);
        }
        MakeExplosion(col.transform.position, transform.rotation, this.transform.parent);
        Destroy(this.gameObject);
    }
 public void register(AlgaeController algae)
 {
     algaeList.Add(algae);
 }
 public void unregister(AlgaeController algae)
 {
     algaeList.Remove(algae);
 }