예제 #1
0
        public bool InLava(IPair pos)
        {
            IPair delta         = pos - Pos;
            int   ground_radius = RADIUS * GameDef.PIXEL_SCALE;

            return(delta.LengthSquare() > ground_radius * ground_radius);
        }
예제 #2
0
        //  override
        public override void Update()
        {
            hp_ += GameDef.UNIT_RECOVER;
            hp_  = Math.Min(hp_, GameDef.UNIT_MAX_HP * GameDef.PIXEL_SCALE);
            //  cd count
            for (int i = 0; i < GameDef.SPELL_COUNT; ++i)
            {
                if (cd_list_[i] > 0)
                {
                    --cd_list_[i];
                }
            }
            //  move
            IPair delta = repusle_.Clone();

            if (order_.Type == 1)
            {
                IPair move_vector = order_.Param1 - Pos;
                if (move_vector.LengthSquare() > speed_ * speed_)
                {
                    move_vector.ChangeLength(speed_);
                }
                else
                {
                    order_.Stop();
                }
                delta.Add(move_vector);
            }
            //  repusle decrease
            long repusle_length_square = repusle_.LengthSquare();
            long repusle_decrease      = speed_ >> GameDef.REPULSE_DECREASE_FACTOR;

            if (repusle_length_square < repusle_decrease * repusle_decrease)
            {
                repusle_.X = repusle_.Y = 0;
            }
            else
            {
                repusle_.ChangeLength((long)Math.Sqrt((double)repusle_length_square) - repusle_decrease);
            }
            Pos.Add(delta);
            GameDef.AdjustCollisionWall(Pos, Radius);
        }