Ejemplo n.º 1
0
    //public void ClearFromRow()
    //{
    //	if (currentRow != null)
    //		currentRow.RemoveOccupier(gameObject);
    //}

    //public void ClearFromRow(GameObject go)
    //{
    //	if (currentRow != null)
    //		currentRow.RemoveOccupier(go);
    //}

    public void Reset()
    {
        //ClearFromRow();
        currentAisle = null;
        //currentRow = null;
        row   = -1;
        aisle = -1;
    }
Ejemplo n.º 2
0
    private void OnTriggerEnter2D(Collider2D collision)
    {
        var sector = collision.GetComponent <SectorHandler>();

        if (sector && currentSector != sector)
        {
            currentSector = sector;
            onEnterSector.Invoke(collision);
        }
    }
Ejemplo n.º 3
0
 public void SetCurrentAisle(SectorHandler s)
 {
     //if (tag == "Blade Point")
     //{
     //	if (currentAisle != null)
     //	{
     //		currentAisle.currentBlade = null;
     //	}
     //	var blade = GetComponentInParent<BladeBehaviourScript>();
     //	s.currentBlade = blade;
     //}
     currentAisle = s;
     //aisle = currentAisle.place;
 }
Ejemplo n.º 4
0
    void PushAway()
    {
        var contacts = GetContacts();

        var sectors = new List <SectorHandler>();

        for (int i = 0; i < contacts.Length; i++)
        {
            var sector = contacts[i].GetComponent <SectorHandler>();
            if (sector)
            {
                sectors.Add(sector);
            }
        }

        if (sectors.Count == 0)
        {
            return;
        }

        SectorHandler sect = sectors[0];

        for (int i = 1; i < sectors.Count; i++)
        {
            if (Mathf.Abs(sectors[i].transform.eulerAngles.z - transform.eulerAngles.z) < Mathf.Abs(sect.transform.eulerAngles.z - transform.eulerAngles.z))
            {
                sect = sectors[i];
            }
        }

        for (int i = 0; i < contacts.Length; i++)
        {
            if (targetTags.Contains(contacts[i].gameObject.tag))
            {
                var mover = contacts[i].GetComponent <Mover>();
                if (!mover)
                {
                    mover = contacts[i].GetComponentInParent <Mover>();
                }
                if (mover)
                {
                    var radius = Vector3.Distance(mover.transform.position, Vector3.zero) + (0.555f * repelSpan);
                    var target = Mathfx.GetPointOnCircle(radius + (UnityEngine.Random.value * 0.1f), sect.transform.eulerAngles.z + 90, Vector3.zero);

                    mover.StartMovement(MoveType.Detour, repelSpeed, target);
                }
            }
        }
    }
Ejemplo n.º 5
0
    protected void SetCoarse()
    {
        if (transform.eulerAngles.z % 45 == 0)
        {
            mover.SetDirection((int)(transform.eulerAngles.z / 45));
            mover.Mobilize(mover.speed);
        }

        var rb = GetComponent <Rigidbody2D>();

        if (!rb)
        {
            Debug.LogWarning("No Rigid Body Found.");
            return;
        }
        var contacts = new Collider2D[50];
        var count    = rb.GetContacts(contacts);

        System.Array.Resize(ref contacts, count);

        var sectors = new List <SectorHandler>();

        for (int i = 0; i < contacts.Length; i++)
        {
            var sector = contacts[i].GetComponent <SectorHandler>();
            if (sector)
            {
                sectors.Add(sector);
            }
        }

        if (sectors.Count == 0)
        {
            return;
        }

        SectorHandler sect = sectors[0];

        for (int i = 1; i < sectors.Count; i++)
        {
            if (Mathf.Abs(sectors[i].transform.eulerAngles.z - transform.eulerAngles.z) < Mathf.Abs(sect.transform.eulerAngles.z - transform.eulerAngles.z))
            {
                sect = sectors[i];
            }
        }

        int direction = 0;

        if (sect.transform.eulerAngles.z >= 0)
        {
            direction = (int)(sect.transform.eulerAngles.z / 45f);
        }
        else
        {
            direction = (int)(360 + sect.transform.eulerAngles.z / 45f);
        }
        mover.SetDirection(direction);
        mover.Mobilize(mover.speed);
        transform.eulerAngles = sect.transform.eulerAngles;
        var radius = Vector3.Distance(transform.position, Vector3.zero) + 0.5f;
        var coarse = Mathfx.GetPointOnCircle(radius, (direction * 45) + 90, Vector3.zero);

        mover.StartMovement(MoveType.Detour, 3, coarse);
    }