コード例 #1
0
ファイル: NecromancerAI.cs プロジェクト: Solsund/dwarfcorp
        public IEnumerable <Act.Status> SummonSkeletons()
        {
            while (true)
            {
                Skeletons.RemoveAll(skeleton => skeleton.IsDead);
                if (SummonTimer.HasTriggered && Skeletons.Count < MaxSkeletons)
                {
                    SummonTimer.Reset(SummonTimer.TargetTimeSeconds);
                    for (int i = Skeletons.Count; i < MaxSkeletons; i += 2)
                    {
                        SummonSkeleton();
                    }
                    yield return(Act.Status.Success);
                }
                else if (SummonTimer.HasTriggered)
                {
                    yield return(Act.Status.Success);
                }
                SummonTimer.Update(DwarfTime.LastTime);

                if (WanderTimer.HasTriggered)
                {
                    Physics.ApplyForce(MathFunctions.RandVector3Box(-5f, 5f, 0.01f, 0.01f, -5f, 5f), 1f);
                    GatherSkeletons();
                }
                WanderTimer.Update(DwarfTime.LastTime);

                if (AttackTimer.HasTriggered)
                {
                    OrderSkeletonsToAttack();
                }
                AttackTimer.Update(DwarfTime.LastTime);
                yield return(Act.Status.Running);
            }
        }
コード例 #2
0
ファイル: HitLower.cs プロジェクト: FreeReign/forkuo
        public static bool ApplyAttack(Mobile m)
        {
            if (IsUnderAttackEffect(m))
                return false;

            m_AttackTable[m] = new AttackTimer(m);
            m.SendLocalizedMessage(1062319); // Your attack chance has been reduced!
            return true;
        }
コード例 #3
0
 /// <summary>
 /// Manages what happens when the game is done
 /// </summary>
 private void EndOfGame()
 {
     AttackTimer.Stop();
     ShowEndWarTextImage();
     WinnerAnnouncement();
     WinnerSound();
     //new ManualResetEvent(false).WaitOne(5000);
     //Application.Exit();
 }
コード例 #4
0
    // Update is called once per frame
    void Update()
    {
        pos = this.transform.position;
        PauseTimer.updateTimer(Time.deltaTime);
        AttackTimer.updateTimer(Time.deltaTime);
        LightTimer.updateTimer(Time.deltaTime);


        if (player.getposition().x < pos.x)
        {
            sr.flipX = false;
            if (player.getposition().y < 6 && pos.x > (initialx - 12) && pos.x <= initialx)
            {
                transform.Translate(Vector2.left * speed / 10);
            }
        }
        if (player.getposition().x > pos.x)
        {
            sr.flipX = true;
            if (player.getposition().y < 6 && pos.x > (initialx - 12) && pos.x <= initialx)
            {
                transform.Translate(Vector2.right * speed / 10);
            }
        }


        //For the pause and the light
        if (wait && PauseTimer.stopped())
        {
            isattacking = true;
            wait        = false;
            AttackTimer.startTimer();
            anim.CrossFade("attack", 0f);
            GameObject.Find("Light").GetComponent <Light> ().intensity = 1.3f;
        }
        if (!wait && AttackTimer.stopped())
        {
            isattacking = false;
            wait        = true;
            PauseTimer.startTimer();
            anim.CrossFade("Idle", 0f);
            LightTimer.startTimer();
        }
        if (wait && LightTimer.stopped())
        {
            GameObject.Find("Light").GetComponent <Light> ().intensity = 3.0f;
        }


        if (healthManager.dead())
        {
            Instantiate(FlowerPrefabs, FlowerInstantiate.transform.position, FlowerInstantiate.rotation);
            Destroy(background_before);
            targetSliderOject.SetActive(false);
            Destroy(gameObject);
        }
    }
コード例 #5
0
        public void Attack()
        {
            AttackTimer.Restart();
            var enemy = Game.Enemies.FirstOrDefault(x => x.Location == Location +
                                                    (Size)(LookDirection == Look.Right
                                                             ? new Point(1, 0)
                                                             : new Point(-1, 0)));

            enemy?.GetDamage(Damage);
        }
コード例 #6
0
 public void Attack()
 {
     SetLookDirectionToPlayer();
     AttackTimer.Restart();
     if (Game.Player.IsBlocking && Game.Player.LookDirection != LookDirection)
     {
         return;
     }
     Game.Player.GetDamage(Damage);
 }
コード例 #7
0
        public override void _Ready()
        {
            this.AddChild(this.LineDrawer);
            RangeArea.Connect("body_entered", this, nameof(On_Area_Entered));
            RangeArea.Connect("body_exited", this, nameof(On_Area_Exited));

            this.AddChild(AttackTimer);
            AttackTimer.OneShot = false;
            AttackTimer.Connect("timeout", this, nameof(On_Attack_Timeout));
        }
コード例 #8
0
        public static bool ApplyAttack(Mobile m)
        {
            if (IsUnderAttackEffect(m))
            {
                return(false);
            }

            m_AttackTable[m] = new AttackTimer(m);
            m.SendLocalizedMessage(1062319);               // Your attack chance has been reduced!
            return(true);
        }
コード例 #9
0
        public static bool ApplyAttack(Mobile m)
        {
            if (IsUnderAttackEffect(m))
            {
                return(false);
            }

            m_AttackTable[m] = new AttackTimer(m);
            BuffInfo.AddBuff(m, new BuffInfo(BuffIcon.HitLowerAttack, 1151315, 1151314, AttackEffectDuration, m, "25"));
            m.SendLocalizedMessage(1062319); // Your attack chance has been reduced!
            return(true);
        }
コード例 #10
0
 public void On_Attack_Timeout()
 {
     if (CloseEnemies.Count > 0)
     {
         this.Attack();
         this.AttackTimer.Start(AttackDelay);
     }
     else
     {
         Attacking = false;
         AttackTimer.Stop();
     }
 }
コード例 #11
0
    protected override void LoadComponents()
    {
        base.LoadComponents();
        unitTraits        = GetComponent <UnitTraits>();
        unitRelationships = GetComponent <UnitRelationships>();
        unitController    = GetComponent <UnitController>();
        unitAnim          = GetComponent <UnitAnimController>();
        attackTimer       = GetComponent <AttackTimer>();
        bodyController    = GetComponent <BodyPartController>();
        combatSkills      = GetComponent <CombatSkills>();

        attack1Parts = bodyController.attack1Parts; //main
        attack2Parts = bodyController.attack2Parts; //off
    }
コード例 #12
0
ファイル: HitLower.cs プロジェクト: Ravenwolfe/xrunuo
        public static void ApplyAttack( Mobile m )
        {
            if ( IsUnderAttackEffect( m ) )
                m_AttackTable[m].Stop();

            TimeSpan duration = AttackEffectDuration;

            if ( m.Weapon is BaseRanged )
                duration -= TimeSpan.FromSeconds( 3.0 );

            BuffInfo.AddBuff( m, new BuffInfo( BuffIcon.HitLowerAttack, 1151315, 1151314, duration, m, "25" ) );

            m_AttackTable[m] = new AttackTimer( m, duration );
            m.SendLocalizedMessage( 1062319 ); // Your attack chance has been reduced!
        }
コード例 #13
0
        public IEnumerable <Act.Status> SummonSkeletons()
        {
            while (true)
            {
                Skeletons.RemoveAll(skeleton => skeleton.IsDead);
                Creature.CurrentCharacterMode  = CharacterMode.Idle;
                Creature.OverrideCharacterMode = false;

                SummonTimer.Update(DwarfTime.LastTime);
                if (SummonTimer.HasTriggered && Skeletons.Count < MaxSkeletons)
                {
                    Creature.CurrentCharacterMode  = Creature.Stats.CurrentClass.AttackMode;
                    Creature.OverrideCharacterMode = true;
                    Creature.Sprite.ReloopAnimations(Creature.Stats.CurrentClass.AttackMode);
                    SoundManager.PlaySound(ContentPaths.Audio.Oscar.sfx_ic_necromancer_summon, Position, true);
                    SummonTimer.Reset(SummonTimer.TargetTimeSeconds);
                    for (int i = Skeletons.Count; i < MaxSkeletons; i += 2)
                    {
                        SummonSkeleton();
                    }
                    yield return(Act.Status.Success);
                }
                else if (SummonTimer.HasTriggered)
                {
                    yield return(Act.Status.Success);
                }

                GatherSkeletonsTimer.Update(DwarfTime.LastTime);
                if (GatherSkeletonsTimer.HasTriggered)
                {
                    var wander = new WanderAct(this, GatherSkeletonsTimer.TargetTimeSeconds, 1.0f, 1.0f);

                    foreach (var status in wander.Run())
                    {
                        GatherSkeletons();
                        yield return(Act.Status.Running);
                    }
                }

                AttackTimer.Update(DwarfTime.LastTime);
                if (AttackTimer.HasTriggered)
                {
                    OrderSkeletonsToAttack();
                }

                yield return(Act.Status.Running);
            }
        }
コード例 #14
0
    private void Attack()
    {
        AttackInfo         myAttack;
        AttackTimer        attackTimer = usm.attackTimer;
        BodyPartController myBody      = usm.bodyController;
        CombatSkills       mySkills    = usm.combatSkills;

        if (Random.Range(0, 100) <= 75)
        {
            if (!myBody.PartTooInjured(attack1Parts))
            {
                AttackAnimation();
                myAttack = mySkills.RequestAttackInfo(attack1Parts[0].MyWeapon());
            }
            else
            {
                string line = "<color=red>" + gameObject.name + " is too injured to attack with their " + attack1Parts[0].MyWeapon().name + "</color>";
                FloatingTextController.CreateFloatingText("Too injured!", transform, Color.red);
                BattleReport.AddToBattleReport(line);
                attackTimer.ResetAttackTimer(7f); //arbitrarily reset attack timer to prevent attack
                                                  //unit reactions -> run away if not player?
                return;
            }
        }
        else
        {
            if (!myBody.PartTooInjured(attack2Parts))
            {
                AttackAnimation();
                myAttack = mySkills.RequestAttackInfo(attack2Parts[0].MyWeapon());
            }
            else
            {
                string line = "<color=red>" + gameObject.name + " is too injured to attack with their " + attack2Parts[0].MyWeapon().name + "</color>";
                FloatingTextController.CreateFloatingText("Too injured!", transform, Color.red);
                BattleReport.AddToBattleReport(line);
                attackTimer.ResetAttackTimer(7f); //arbitrarily reset attack timer to prevent attack
                                                  //unit reactions -> run away if not player?
                return;
            }
        }
        Debug.Log(gameObject.name + " attacking with reset timer of " + myAttack.speed);
        targetBody.RecieveAttack(myAttack, transform); //should reset back to whatever weapon was used
        attackTimer.ResetAttackTimer(myAttack.speed);
    }
コード例 #15
0
        public void On_Area_Entered(Node body)
        {
            if (body.IsInGroup("Enemies"))
            {
                Enemy enemy = body.GetOwner <Enemy>();

                CloseEnemies.Add(WeakRef(enemy));

                enemy.Connect("EnemyDied", this, nameof(this.RemoveEnemy));

                if (CloseEnemies.Count > 0 && !Attacking)
                {
                    Attacking = true;
                    this.Attack();
                    AttackTimer.Start(AttackDelay);
                }
            }
        }
コード例 #16
0
ファイル: HitLower.cs プロジェクト: nogu3ira/xrunuo
        public static void ApplyAttack(Mobile m)
        {
            if (IsUnderAttackEffect(m))
            {
                m_AttackTable[m].Stop();
            }

            TimeSpan duration = AttackEffectDuration;

            if (m.Weapon is BaseRanged)
            {
                duration -= TimeSpan.FromSeconds(3.0);
            }

            BuffInfo.AddBuff(m, new BuffInfo(BuffIcon.HitLowerAttack, 1151315, 1151314, duration, m, "25"));

            m_AttackTable[m] = new AttackTimer(m, duration);
            m.SendLocalizedMessage(1062319);               // Your attack chance has been reduced!
        }
コード例 #17
0
        /// <summary>
        /// Updates a Monster
        /// </summary>
        public new void Update()
        {
            base.Update();
            AttackTimer.Update();
            MoveTimer.Update();

            if (MoveTimer.ActionReady)
            {
                if (MoveToLowestWeight())
                {
                    return;
                }
                if (GameManager.Random.Next(0, 100) == 0)
                {
                    RegenHealth();
                    MoveRandomOne();
                }
            }
        }
コード例 #18
0
 public void Attack()
 {
     SetLookDirectionToPlayer();
     AttackTimer.Restart();
     SpawnSkeleton();
 }