コード例 #1
0
    Vector2 GetValidDest(Vector2 Destination)
    {
        Vector2 PosInUnit = ZDGameRule.WorldToUnit(transform.position);
        Vector2 DesInUnit = ZDGameRule.WorldToUnit(ZDGameRule.QuadrifyDirection(Destination, transform.position));

        for (int i = 0; i < 2; ++i)
        {
            if (!PosInUnit[i].Equals(DesInUnit[i]))
            {
                int     Delta  = (PosInUnit[i] < DesInUnit[i] ? 1 : -1);
                Vector2 CurPos = PosInUnit;

                while (true)
                {
                    //Move To Currently Checking Position.
                    CurPos[i] += Delta;
                    if (!ZDMap.IsUnitInMap(CurPos) || ZDMap.HitAtUnit(CurPos, EObjectType.Obstacle) != null)
                    {
                        //Return To Last Position.
                        CurPos[i] -= Delta;
                        return(ZDGameRule.UnitToWorld(CurPos));
                    }
                    if (CurPos[i].Equals(DesInUnit[i]))
                    {
                        break;
                    }
                }
                return(ZDGameRule.UnitToWorld(DesInUnit));
            }
        }
        return(transform.position);
    }
コード例 #2
0
    protected override void Sprint(Vector2 Destination)
    {
        NewDestination = true;
        //Save Destination
        SprintDestination = ZDGameRule.WorldUnify(ZDGameRule.QuadrifyDirection(Destination, transform.position));

        //PlaySound
        if (MoveSound && audioSource)
        {
            audioSource.PlayOneShot(MoveSound);
        }
    }
コード例 #3
0
    void FaceTo(Vector2 Direction)
    {
        //Save Attack Direction
        AttackRad = ZDGameRule.QuadRadius(Direction);

        // Set Scale Direction
        if (!Direction.x.Equals(0))
        {
            sprite.flipX = Direction.x > 0 ? true: false;
        }
        Direction = ZDGameRule.QuadrifyDirection(Direction);
        // Set Animation Direction
        animator.SetInteger("AtkVertical", (int)Direction.y);
        animator.SetInteger("AtkHorizontal", (int)Direction.x);
        Debug.Log("Direction" + new Vector2(Direction.x, Direction.y));
    }
コード例 #4
0
ファイル: Ruso.cs プロジェクト: Teddy12155555/ZoneDepict
    public override void InputAttack(Vector2 AttackDirection, EAttackType Type)
    {
        switch (Type)
        {
        case EAttackType.N:
            break;

        default:
            if (Soul == (int)EAttackType.A &&
                !ZDGameRule.QuadrifyDirection(AttackDirection).y.Equals(0))
            {
                return;
            }
            break;
        }
        base.InputAttack(AttackDirection, Type);
    }