Beispiel #1
0
        // --- Overrides:
        protected override void add_moves()
        {
            Move     tempMove  = new Move();
            MovePart tempMove1 = new MovePart();
            MovePart tempMove2 = new MovePart();

            for (int i = 1; i < Chessboard.MAX; i++)
            {
                // Up + Right:
                tempMove1.update(Direction.UP, i);
                tempMove2.update(Direction.RIGHT, i);
                tempMove.update(tempMove1, tempMove2);
                movements.Add(tempMove);

                // Up + Left:
                tempMove1.update(Direction.UP, i);
                tempMove2.update(Direction.LEFT, i);
                tempMove.update(tempMove1, tempMove2);
                movements.Add(tempMove);

                // Down + Right:
                tempMove1.update(Direction.DOWN, i);
                tempMove2.update(Direction.RIGHT, i);
                tempMove.update(tempMove1, tempMove2);
                movements.Add(tempMove);

                // Down + Left:
                tempMove1.update(Direction.DOWN, i);
                tempMove2.update(Direction.LEFT, i);
                tempMove.update(tempMove1, tempMove2);
                movements.Add(tempMove);
            }
        }
 void Setup()
 {
     legsObject = Instantiate(legsPrefab, transform.position, Quaternion.identity);
     legsObject.transform.SetParent(transform);
     legsObject.transform.localRotation = new Quaternion(0, 0, 0, 0);
     legsObject.transform.localPosition = Vector3.zero;
     move         = legsObject.GetComponent <MovePart>();
     move.rb      = GetComponentInParent <Rigidbody>();
     move.canJump = true;
     move.player  = GetComponentInParent <Player>();
 }
Beispiel #3
0
    /// <summary>
    /// Takes in a JsonStream that is based from SkillPartBase and returns what effect it should be read as
    /// </summary>
    /// <returns>An empty object of the type the given data can fill</returns>
    public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer)
    {
        object target = null;

        if (reader.TokenType == JsonToken.Null)
        {
            return(null);
        }

        var jObject = JToken.Load(reader);

        if (jObject["effect"] != null)
        {
            target = new AddTriggerPart();
        }
        else if (jObject["damage"] != null)
        {
            target = new DamagePart();
        }
        else if (jObject["healing"] != null)
        {
            target = new HealingPart();
        }
        else if (jObject["direction"] != null)
        {
            target = new MovePart();
        }
        else if (jObject["statMod"] != null)
        {
            target = new StatChangePart();
        }
        else if (jObject["status"] != null)
        {
            target = new StatusEffectPart();
        }
        else if (jObject["effectType"] != null)
        {
            target = new UniqueEffectPart();
        }
        else if (jObject["chanceOutOf"] != null)
        {
            target = new ConnectedChancePart();
        }
        else
        {
            throw new ArgumentException("Invalid source type");
        }

        serializer.Populate(jObject.CreateReader(), target);

        return(target);
    }
Beispiel #4
0
        // --- Overrides:
        protected override void add_moves()
        {
            Move     tempMove  = new Move();
            MovePart tempMove1 = new MovePart();
            MovePart tempMove2 = new MovePart();

            tempMove1.update(Direction.UP, 2);
            tempMove2.update(Direction.RIGHT, 1);
            tempMove.update(tempMove1, tempMove2);
            movements.Add(tempMove);

            tempMove1.update(Direction.UP, 2);
            tempMove2.update(Direction.LEFT, 1);
            tempMove.update(tempMove1, tempMove2);
            movements.Add(tempMove);

            tempMove1.update(Direction.RIGHT, 2);
            tempMove2.update(Direction.UP, 1);
            tempMove.update(tempMove1, tempMove2);
            movements.Add(tempMove);

            tempMove1.update(Direction.RIGHT, 2);
            tempMove2.update(Direction.DOWN, 1);
            tempMove.update(tempMove1, tempMove2);
            movements.Add(tempMove);

            tempMove1.update(Direction.DOWN, 2);
            tempMove2.update(Direction.RIGHT, 1);
            tempMove.update(tempMove1, tempMove2);
            movements.Add(tempMove);

            tempMove1.update(Direction.DOWN, 2);
            tempMove2.update(Direction.LEFT, 1);
            tempMove.update(tempMove1, tempMove2);
            movements.Add(tempMove);

            tempMove1.update(Direction.LEFT, 2);
            tempMove2.update(Direction.UP, 1);
            tempMove.update(tempMove1, tempMove2);
            movements.Add(tempMove);

            tempMove1.update(Direction.LEFT, 2);
            tempMove2.update(Direction.DOWN, 1);
            tempMove.update(tempMove1, tempMove2);
            movements.Add(tempMove);
        }
Beispiel #5
0
    public void MoveEntity()
    {
        MovePart movePart = m_Part[(int)EntityPartType.MovePart] as MovePart;

        if (EnType == EntityType.Monster)
        {
            if (movePart != null)
            {
                movePart.MoveTo(Vector3.zero);
            }
        }
        else if (EnType == EntityType.Hero)
        {
            if (movePart != null)
            {
                movePart.MoveTo(Vector3.zero);
            }
        }
    }
Beispiel #6
0
        public IActivity Tick( Actor self )
        {
            var unit = self.traits.Get<Unit>();
            var mobile = self.traits.Get<Mobile>();

            if( move != null )
            {
                move.TickMove( self, mobile, this );
                return this;
            }

            if (destination == self.Location)
                return NextActivity;

            if( path == null )
            {
                if (ticksBeforePathing > 0)
                {
                    --ticksBeforePathing;
                    return this;
                }

                path = getPath( self, mobile ).TakeWhile( a => a != self.Location ).ToList();
                SanityCheckPath( mobile );
            }

            if( path.Count == 0 )
            {
                destination = mobile.toCell;
                return this;
            }

            destination = path[ 0 ];

            var nextCell = PopPath( self, mobile );
            if( nextCell == null )
                return this;

            int2 dir = nextCell.Value - mobile.fromCell;
            var firstFacing = Util.GetFacing( dir, unit.Facing );
            if( firstFacing != unit.Facing )
            {
                path.Add( nextCell.Value );

                return new Turn( firstFacing ) { NextActivity = this };
            }
            else
            {
                mobile.toCell = nextCell.Value;
                move = new MoveFirstHalf(
                    Util.CenterOfCell( mobile.fromCell ),
                    Util.BetweenCells( mobile.fromCell, mobile.toCell ),
                    unit.Facing,
                    unit.Facing,
                    0 );

                move.TickMove( self, mobile, this );

                return this;
            }
        }