Ejemplo n.º 1
0
        protected override void OnUpdate()
        {
            base.OnUpdate();

            if (frozenTimeLeft > 0)
            {
                return;
            }

            switch (state)
            {
            case StateIdle: {
                if (currentTransitionState == AnimState.Idle)
                {
                    // InhaleStart
                    SetTransition((AnimState)1, true, delegate {
                            // Inhale
                            SetTransition((AnimState)2, true, delegate {
                                // ExhaleStart
                                SetTransition((AnimState)3, true, delegate {
                                    state      = StateAttacking;
                                    smokesLeft = MathF.Rnd.Next(6, 12);
                                });
                            });
                        });
                }

                break;
            }

            case StateAttacking: {
                if (attackTime <= 0f)
                {
                    attackTime = 60f;

                    SetAnimation((AnimState)5);
                    SetTransition((AnimState)4, true, delegate {
                            Vector3 pos = Transform.Pos;

                            Smoke smoke = new Smoke();
                            smoke.OnAttach(new ActorInstantiationDetails {
                                Api = api,
                                Pos = new Vector3(pos.X - 26f, pos.Y - 18f, pos.Z - 20f)
                            });
                            api.AddActor(smoke);

                            smokesLeft--;
                            if (smokesLeft <= 0)
                            {
                                state = StateIdle;
                                SetAnimation(AnimState.Idle);
                            }
                        });
                }
                else
                {
                    attackTime -= Time.TimeMult;
                }
                break;
            }
            }
        }