コード例 #1
0
    // Update is called once per frame
    void Update()
    {
        if (moving == true)
        {
            transform.position = Vector3.Lerp(tempP, tempN, t);
            t += Time.deltaTime * mapSpeed;

            if (t >= 1)
            {
                CurrentLocation = Path[Path.Length - 1 - step];
                Path[Path.Length - 1 - step].GetComponent <Pathnode>().CurrentOccupant = gameObject;
                Path[Path.Length - step].GetComponent <Pathnode>().CurrentOccupant     = null;
                MovePoints -= CurrentLocation.GetComponent <Pathnode>().GetMPRequired();

                GetComponent <Attack>().SetDef();

                if (Path.Length - 1 - step <= 0)
                {
                    moving = false;
                    Debug.Log("checked " + runs + " tiles");

                    step = 1;
                    Checked.Clear();
                    CanMoveTo.Clear();
                    ToCheck.Clear();
                    ThisMove.Clear();
                    thisClicker.Clear();

                    transform.position = CurrentLocation.GetComponent <Tile>().UnitAnchor.transform.position;
                    //PlaceUnit(CurrentLocation);

                    if (CurrentLocation.GetComponent <FactionSwitcher>() != null)
                    {
                        CurrentLocation.GetComponent <FactionSwitcher>().SwitchUnit();
                    }

                    t = 0;

                    if (GetComponent <Unit>().controlledByAI == true)
                    {
                        GetComponent <Unit>().AIOverlord.GetComponent <AICombat>().LocateTarget(gameObject);
                    }

                    return;
                }
                step   += 1;
                t       = 0;
                tempP   = Path[Path.Length - step].transform.position;
                tempP.y = transform.position.y;
                tempN   = Path[Path.Length - step - 1].transform.position;
                tempN.y = transform.position.y;
                transform.LookAt(tempN);
            }
        }
    }
コード例 #2
0
 public void Cancel()
 {
     click.Clear();
     GetComponent <CanvasGroup>().alpha          = 0;
     GetComponent <CanvasGroup>().interactable   = false;
     GetComponent <CanvasGroup>().blocksRaycasts = false;
 }