Ejemplo n.º 1
0
        protected override void Move(Vector3 goal, bool snap = false)
        {
            Vector3 position = base.transform.position;

            if (snap || AlwaysSnapOverride)
            {
                velocity = Vector3.zero;
                base.transform.position = goal;
            }
            else
            {
                Vector3 position2 = base.transform.position;
                for (int i = 0; i < 3; i++)
                {
                    float pPos           = position2[i];
                    float equilibriumPos = goal[i];
                    float pVel           = velocity[i];
                    FeepMath.calcDampedSimpleHarmonicMotion(ref pPos, ref pVel, equilibriumPos, Time.deltaTime, SpringFrequency, SpringDamping);
                    position2[i] = pPos;
                    velocity[i]  = pVel;
                }
                base.transform.position = position2;
            }
            if (base.transform.position != position)
            {
                Moved.InvokeSafe();
            }
        }
Ejemplo n.º 2
0
    public bool MoveTo(Tile targetTile)
    {
        if (targetTile == null)
        {
            DebugEx.LogWarning <Unit>("Cannot move to a null tile.");
            return(false);
        }

        if (!targetTile.Blocked)
        {
            Moved.InvokeSafe(new UnitMoveEvent(this, targetTile));
            //targetTile.SetOccupant(this);
            return(true);
        }

        return(false);
    }