示例#1
0
 public override void reloadSprite()
 {
     if (Sprite == null)
     {
         Sprite = new AnimatedSprite(ModEntry.Config.DinoTexture);
     }
     else
     {
         Sprite.textureName.Value = ModEntry.Config.DinoTexture;
     }
     if (ModEntry.Config.DinoColorType.ToLower() != "default")
     {
         Sprite.spriteTexture = FamiliarsUtils.ColorFamiliar(Sprite.Texture, mainColor, redColor, greenColor, blueColor);
     }
     Sprite.SpriteWidth  = 32;
     Sprite.SpriteHeight = 32;
     Sprite.UpdateSourceRect();
     HideShadow = true;
 }
示例#2
0
        public override void behaviorAtGameTick(GameTime time)
        {
            invincibleCountdown = 1000;

            chargingMonster = false;
            if (!(currentLocation is SlimeHutch))
            {
                foreach (NPC npc in currentLocation.characters)
                {
                    if (npc is Familiar)
                    {
                        continue;
                    }

                    if (npc is Monster && FamiliarsUtils.withinMonsterThreshold(this, (Monster)npc, 2))
                    {
                        chargingMonster = true;
                        if (currentTarget == null || Vector2.Distance(npc.position, position) < Vector2.Distance(currentTarget.position, position))
                        {
                            currentTarget = (Monster)npc;
                        }
                    }
                }
            }

            if (attackState.Value == 1)
            {
                IsWalkingTowardPlayer = false;
                Halt();
            }
            else if (withinPlayerThreshold() && followingOwner)
            {
                if (withinPlayerThreshold(1))
                {
                    Halt();
                }
                else
                {
                    IsWalkingTowardPlayer = true;
                }
            }
            else
            {
                IsWalkingTowardPlayer    = false;
                nextChangeDirectionTime -= time.ElapsedGameTime.Milliseconds;
                nextWanderTime          -= time.ElapsedGameTime.Milliseconds;
                if (nextChangeDirectionTime < 0)
                {
                    nextChangeDirectionTime = Game1.random.Next(500, 1000);
                    facingDirection.Value   = (facingDirection.Value + (Game1.random.Next(0, 3) - 1) + 4) % 4;
                }
                if (nextWanderTime < 0)
                {
                    if (wanderState)
                    {
                        nextWanderTime = Game1.random.Next(1000, 2000);
                    }
                    else
                    {
                        nextWanderTime = Game1.random.Next(1000, 3000);
                    }
                    wanderState = !wanderState;
                }
                if (wanderState)
                {
                    moveLeft = (moveUp = (moveRight = (moveDown = false)));
                    tryToMoveInDirection(facingDirection.Value, false, DamageToFarmer, isGlider);
                }
            }
            timeUntilNextAttack -= time.ElapsedGameTime.Milliseconds;
            if (attackState.Value == 0 && chargingMonster)
            {
                firing.Set(false);
                if (timeUntilNextAttack < 0)
                {
                    timeUntilNextAttack = 0;
                    attackState.Set(1);
                    nextFireTime  = 500;
                    totalFireTime = 3000;
                    if (ModEntry.Config.DinoSoundEffects)
                    {
                        currentLocation.playSound("croak", NetAudio.SoundContext.Default);
                    }
                    return;
                }
            }
            else if (totalFireTime > 0)
            {
                if (!firing)
                {
                    if (currentTarget != null)
                    {
                        faceGeneralDirection(currentTarget.Position, 0, false);
                    }
                }
                totalFireTime -= time.ElapsedGameTime.Milliseconds;
                if (nextFireTime > 0)
                {
                    nextFireTime -= time.ElapsedGameTime.Milliseconds;
                    if (nextFireTime <= 0)
                    {
                        if (!firing.Value)
                        {
                            firing.Set(true);
                            currentLocation.playSound("furnace", NetAudio.SoundContext.Default);
                        }
                        float   fire_angle  = 0f;
                        Vector2 shot_origin = new Vector2((float)GetBoundingBox().Center.X - 32f * scale, (float)GetBoundingBox().Center.Y - 32f * scale);
                        switch (facingDirection.Value)
                        {
                        case 0:
                            yVelocity      = -1f;
                            shot_origin.Y -= 74f * scale;
                            fire_angle     = 90f;
                            break;

                        case 1:
                            xVelocity      = -1f;
                            shot_origin.X += 74f * scale;
                            fire_angle     = 0f;
                            break;

                        case 2:
                            yVelocity      = 1f;
                            fire_angle     = 270f;
                            shot_origin.Y += 74 * scale;
                            break;

                        case 3:
                            xVelocity      = 1f;
                            shot_origin.X -= 74f * scale;
                            fire_angle     = 180f;
                            break;
                        }
                        fire_angle += (float)Math.Sin((double)((float)totalFireTime / 1000f * 180f) * 3.1415926535897931 / 180.0) * 25f;
                        Vector2 shot_velocity = new Vector2((float)Math.Cos((double)fire_angle * 3.1415926535897931 / 180.0), -(float)Math.Sin((double)fire_angle * 3.1415926535897931 / 180.0));
                        shot_velocity *= 10f;
                        BasicProjectile projectile = new BasicProjectile(GetDamage(), 10, 0, 1, 0.196349546f, shot_velocity.X, shot_velocity.Y, shot_origin, "", "", false, true, currentLocation, this, false, null);
                        projectile.ignoreTravelGracePeriod.Value = true;
                        projectile.maxTravelDistance.Value       = GetFireDistance();
                        currentLocation.projectiles.Add(projectile);
                        nextFireTime = 50;
                    }
                }
                if (totalFireTime <= 0)
                {
                    AddExp(1);
                    totalFireTime = 0;
                    nextFireTime  = 0;
                    attackState.Set(0);
                    timeUntilNextAttack = Game1.random.Next(1000, 2000);
                }
            }
        }
示例#3
0
 public override void reloadSprite()
 {
     if (this.Sprite == null)
     {
         this.Sprite = new AnimatedSprite(ModEntry.Config.DinoTexture);
     }
     else
     {
         this.Sprite.textureName.Value = ModEntry.Config.DinoTexture;
     }
     if (ModEntry.Config.DinoColorType.ToLower() != "default")
     {
         typeof(AnimatedSprite).GetField("spriteTexture", BindingFlags.NonPublic | BindingFlags.Instance).SetValue(Sprite, FamiliarsUtils.ColorFamiliar(Sprite.Texture, mainColor, redColor, greenColor, blueColor));
     }
     this.Sprite.SpriteWidth  = 32;
     this.Sprite.SpriteHeight = 32;
     this.Sprite.UpdateSourceRect();
     base.HideShadow = true;
 }