Exemple #1
0
	// Play animation for when playing is moving forwards or backwards through
	// the air
	public void HandleAirHangTime() {
		if (Mathf.Sign(playerController.velocity.x) < 0) {
			m_anim.Play(m_airB);
		} else {
			m_anim.Play(m_airF);
		}
	}
Exemple #2
0
 public void StartIdling()
 {
     moveLeft      = false;
     moveRight     = false;
     lastMoveLeft  = true;
     lastMoveRight = true;
     mySpriteAnim.Play(idle);
 }
Exemple #3
0
    public void PlayOpenAnimation()
    {
        if (!spriteAnim)
        {
            spriteAnim = GetComponent <SpriteAnim>();
        }

        spriteAnim.Play(openClip);
    }
Exemple #4
0
 private void OnTriggerEnter2D(Collider2D collision)
 {
     if (ToFloor != FloorManager.GetFloorIndex() || FloorManager.IsLevelStarted())
     {
         BlackScreen.FadeInOut(MyAnim.FrameTime * MyAnim.Sprites.Length);
         PlayerBase.LockControls(true);
         MyAnim.Play();
     }
 }
Exemple #5
0
 public void ClosedStart()
 {
     if (!closed)
     {
         SfxManager.instance.PlaySound(SoundType.DOOR_CLOSE);
         animator.Play(closeAnim);
         closed = true;
     }
     barrier.enabled = true;
 }
Exemple #6
0
 public void SetEnergy(float energyAmt)
 {
     energyBarSprite.sprite = this.barFrames[Mathf.Clamp(Mathf.RoundToInt(MathUtil.Map(energyAmt, 0, 100, 0, overloadFrame - 1)), 0, barFrames.Length - 1)];
     if (energyAmt == 199 && energyBoltSprite.GetCurrentAnimation() != energyBoltOverload)
     {
         energyBoltSprite.Play(energyBoltOverload);
     }
     if (energyAmt < 199 && gameObject.activeSelf)
     {
         energyBoltSprite.Play(energyBoltOff);
     }
 }
Exemple #7
0
 public void SetMode(NPCMode setMode)
 {
     mode = setMode;
     if (setMode == NPCMode.ALLY)
     {
         ConvertToAlly();
         StartCoroutine(AddPointDelay(0.4f));
     }
     else if (setMode == NPCMode.NONCON)
     {
         sprAnim.Play("npc/noncon_walk", 0);
     }
 }
Exemple #8
0
    void ChangeFormation(TargetHandler.FormationMode form)
    {
        switch (form)
        {
        case TargetHandler.FormationMode.LINE:
            sprAnim.Play("player/queue", 0);
            break;

        case TargetHandler.FormationMode.FOLLOW_CURSOR:
            sprAnim.Play("player/walk", 0);
            break;
        }
    }
 public void HandleRunning(float direction)
 {
     if (m_anim.GetCurrentAnimation() == m_run)
     {
         if (Mathf.Sign(playerController.velocity.x) == Mathf.Sign(direction))
         {
             PlayIfNotWasPlaying(m_run);
         }
         else
         {
             m_anim.Play(m_run);
             FlipDirection(direction);
         }
     }
 }
Exemple #10
0
        /// <summary>
        /// Api's reimplementation of <see cref="KillAnimation.CoPerformKill"/><br/>
        /// Shouldn't be used in regular code
        /// </summary>
        public static IEnumerator CoPerformCustomKill(this KillAnimation anim, PlayerControl source, PlayerControl target, CustomMurderOptions options)
        {
            FollowerCamera camera        = Camera.main !.GetComponent <FollowerCamera>();
            bool           isParticipant = source == PlayerControl.LocalPlayer || target == PlayerControl.LocalPlayer;

            KillAnimation.SetMovement(target, false);
            if (isParticipant)
            {
                camera.Locked = true;
            }
            target.Die(DeathReason.Kill);
            DeadBody deadBody = Object.Instantiate(anim.bodyPrefab); // https://github.com/Herysia/AmongUsTryhard
            Vector3  vector   = target.transform.position + anim.BodyOffset;

            vector.z = vector.y / 1000;
            deadBody.transform.position = vector;
            deadBody.ParentId           = target.PlayerId;
            target.SetPlayerMaterialColors(deadBody.GetComponent <Renderer>());
            if (!options.HasFlag(CustomMurderOptions.NoSnap))
            {
                KillAnimation.SetMovement(source, false);
                SpriteAnim sourceAnim = source.GetComponent <SpriteAnim>();
                yield return(new WaitForAnimationFinish(sourceAnim, anim.BlurAnim));

                source.NetTransform.SnapTo(target.transform.position);
                sourceAnim.Play(source.MyPhysics.IdleAnim, 1f);
                KillAnimation.SetMovement(source, true);
            }
            KillAnimation.SetMovement(target, true);
            if (isParticipant)
            {
                camera.Locked = false;
            }
        }
Exemple #11
0
 public void PlayAnim(PlayerAnim anim)
 {
     if (!animator.IsPlaying(animations[anim]))
     {
         animator.Play(animations[anim]);
     }
 }
Exemple #12
0
 public Hero(Texture2D spritesheet, Rectangle hitbox, Vector2 hitboxoffset)
     : base(spritesheet, hitbox, null, hitboxoffset)
 {
     _idleAnim = new SpriteAnim(spritesheet, 0, 1, 16,16,0, new Vector2(8f,16f));
     _runAnim = new SpriteAnim(spritesheet, 1, 7, 16, 16, 60, new Vector2(8f,16f));
     _runAnim.Play();
 }
Exemple #13
0
 public Hero(Texture2D spritesheet, Rectangle hitbox, Vector2 hitboxoffset)
     : base(spritesheet, hitbox, null, hitboxoffset)
 {
     _idleAnim = new SpriteAnim(spritesheet, 0, 1, 16, 16, 0, new Vector2(8f, 16f));
     _runAnim  = new SpriteAnim(spritesheet, 1, 7, 16, 16, 60, new Vector2(8f, 16f));
     _runAnim.Play();
 }
Exemple #14
0
    // Use this for initialization
    void Start()
    {
        controller2D     = GetComponent <Controller2D> ();
        playerController = GetComponent <PlayerController> ();

        m_anim = GetComponent <SpriteAnim> ();
        m_anim.Play(m_idle);
    }
Exemple #15
0
 public void StartSpriteAnim(SO_SpriteAnimObject _sOSpriteAnimObject)
 {
     inUse = true;
     sOSpriteAnimObject = _sOSpriteAnimObject;
     this.gameObject.SetActive(true);
     spriteAnim.Play(sOSpriteAnimObject.animClip);
     StartCoroutine(InSpriteAnim());
 }
Exemple #16
0
    // SPRITE ANIM / POWERTOOLS ======================================================

    public static void PlayAnim(this GameObject go, AnimationClip anim)
    {
        SpriteAnim compAnim = go.GetComponent <SpriteAnim>();

        if (compAnim != null)
        {
            compAnim.Play(anim);
        }
    }
Exemple #17
0
    // Use this for initialization
    void Start()
    {
        //controller2D = GetComponent<Controller2D> ();
        playerController = GetComponent <PlayerController> ();

        m_anim = GetComponent <SpriteAnim> ();
        m_anim.Play(m_idle);

        m_clip_queue = new Queue();
    }
Exemple #18
0
        public ManOWar(Texture2D spritesheet, Rectangle hitbox, List<Vector2> hitPolyPoints, Vector2 hitboxoffset)
            : base(spritesheet, hitbox, hitPolyPoints, hitboxoffset)
        {
            _idleAnim = new SpriteAnim(spritesheet, 1, 4, 16, 16, 500, new Vector2(8, 8), true, false, Helper.Random.Next(4));
            _idleAnim.Play();
            _hitAnim = new SpriteAnim(spritesheet, 7, 4, 16, 16, 500, new Vector2(8, 8), true, false, _idleAnim.CurrentFrame);
            _hitAnim.Play();

            Speed.X = Helper.RandomFloat(-0.1f, 0.1f);
        }
        // Play the animation from the list of clips, using it's index
        public void SetClip(int index)
        {
            // Check there's an anim component and a corresponding id for the clip, and play it!
            SpriteAnim animComponent = GetComponentInChildren <SpriteAnim>(true);

            if (animComponent != null && index >= 0 && index < m_anims.Length)
            {
                animComponent.Play(m_anims[index]);
            }
        }
    void Update()
    {
        bool getFound = motor.GetFoundTarget();



        if (getFound != foundState)
        {
            foundState = getFound;
            if (foundState)
            {
                sprAnim.Play("enemy/wand", 0);
            }
            else
            {
                sprAnim.Play("enemy/scan", 0);
            }
        }
    }
Exemple #21
0
        public ManOWar(Texture2D spritesheet, Rectangle hitbox, List <Vector2> hitPolyPoints, Vector2 hitboxoffset)
            : base(spritesheet, hitbox, hitPolyPoints, hitboxoffset)
        {
            _idleAnim = new SpriteAnim(spritesheet, 1, 4, 16, 16, 500, new Vector2(8, 8), true, false, Helper.Random.Next(4));
            _idleAnim.Play();
            _hitAnim = new SpriteAnim(spritesheet, 7, 4, 16, 16, 500, new Vector2(8, 8), true, false, _idleAnim.CurrentFrame);
            _hitAnim.Play();

            Speed.X = Helper.RandomFloat(-0.1f, 0.1f);
        }
Exemple #22
0
        public Eyes(Texture2D spritesheet, Rectangle hitbox, List <Vector2> hitPolyPoints, Vector2 hitboxoffset)
            : base(spritesheet, hitbox, hitPolyPoints, hitboxoffset)
        {
            _idleAnim = new SpriteAnim(spritesheet, 2, 4, 16, 16, 100, new Vector2(8, 8), true, true, 0);
            _idleAnim.Play();
            _hitAnim = new SpriteAnim(spritesheet, 8, 4, 16, 16, 100, new Vector2(8, 8), true, true, _idleAnim.CurrentFrame);
            _hitAnim.Play();

            Speed.X = Helper.RandomFloat(-0.3f, 0.3f);
            Speed.Y = Helper.RandomFloat(-0.2f, 0.2f);
        }
Exemple #23
0
    //Vector2 direction;

    public void LaunchProjectile(SO_Projectile _projSO, Vector2 _direction, Vector2 startPos, float flipXDirection = 0f /* , ParticleSystem _partSys = null, Transform _partSysParent = null */)
    {
        inUse = true;
        mySpriteR.sortingOrder = _projSO.sortingOrder;
        projDurationTimer      = 0f;
        //
        if (flipXDirection < 0f)
        {
            mySpriteR.flipX = true;
        }
        // partSys = _partSys;
        // partSysParent = _partSysParent;
        projSO       = _projSO;
        projDuration = projSO.duration;
        curProjSpeed = projSO.maxSpeed;
        // If projectile uses a speed curve.
        if (projSO.useSpeedCurve)
        {
            curveTimer           = 0f;
            curveTimerAdjustment = 1 / projDuration;
            speedCurve           = projSO.speedCurve;
        }
        //contactFilter = projSO.contactFilter;
        //direction = _direction;
        this.transform.position  = new Vector3(startPos.x, startPos.y, this.transform.position.z);
        this.transform.up        = _direction;
        this.transform.position += (Vector3)_direction.normalized * projSO.spawnDistance;
        // Activating the game object here in case the animation coroutine needs to be,
        this.gameObject.SetActive(true);
        // Check if the sprite is animated, if yes start animation coroutine? Else just take the single sprite.
        if (!projSO.animated)
        {
            mySpriteR.sprite = projSO.sprite;
        }
        else
        {
            // Setup animation.
            // animSprites = projSO.animSprites;
            // animTimings = projSO.animTimings;
            // animTotalDuration = projSO.animTotalDuration;
            // mySpriteR.sprite = animSprites[0];
            // StartCoroutine(AnimateProjectile());
            // With PowerSpriteAnimator.
            if (projDuration < projSO.animClip.length)
            {
                //Debug.Log("Hello, be careful, a projectile that was just started has a duration that is shorter then its animation clip's lenght(duration). This means that the animation clip will not fully play once.");
            }
            mySpriteAnim.Play(projSO.animClip);
        }
        // Assign collider.
        myCol.points = projSO.col.points;
        //myCol = projSO.col;
        StartCoroutine(MoveProjectile());
    }
    public void SetCombo(int combo)
    {
        this.comboText.transform.localScale = (Vector3)Vector2.one * MathUtil.Map(GameManager.instance.combo, 1, 100, 1, 2) + Vector3.forward;
        if (this.combo < combo)
        {
            animator.Play(comboAnim);
        }

        this.combo          = combo;
        this.comboText.text = combo.ToString() + "x";
    }
Exemple #25
0
        public Eyes(Texture2D spritesheet, Rectangle hitbox, List<Vector2> hitPolyPoints, Vector2 hitboxoffset)
            : base(spritesheet, hitbox, hitPolyPoints, hitboxoffset)
        {
            _idleAnim = new SpriteAnim(spritesheet, 2, 4, 16, 16, 100, new Vector2(8, 8), true, true, 0);
            _idleAnim.Play();
            _hitAnim = new SpriteAnim(spritesheet, 8, 4, 16, 16, 100, new Vector2(8, 8), true, true, _idleAnim.CurrentFrame);
            _hitAnim.Play();

            Speed.X = Helper.RandomFloat(-0.3f, 0.3f);
            Speed.Y = Helper.RandomFloat(-0.2f, 0.2f);
        }
 private void SendSpikes(int amt)
 {
     faceAnimator.Play(faceAnim);
     spikeAnimator.Play(spikeAnim);
     for (int i = 0; i < amt; i++)
     {
         var spikeCopy = Instantiate(spike);
         spikeCopy.transform.position = transform.position;
         var randAngle   = Random.Range(0, 360);
         var spikeBullet = spikeCopy.GetComponent <Bullet>();
         spikeBullet.velocity    = new Vector2(Mathf.Cos(randAngle * Mathf.Deg2Rad), Mathf.Sin(randAngle * Mathf.Deg2Rad)).normalized * 0.25f;
         spikeBullet.angleOffset = 180;
     }
 }
Exemple #27
0
        public Turret(Texture2D spritesheet, Rectangle hitbox, List<Vector2> hitPolyPoints, Vector2 hitboxoffset)
            : base(spritesheet, hitbox, hitPolyPoints, hitboxoffset)
        {
            _idleAnim = new SpriteAnim(spritesheet, 4, 2, 16, 16, 200, new Vector2(8, 8), true, false, 0);
            _idleAnim.Play();
            _hitAnim = new SpriteAnim(spritesheet, 10, 2, 16, 16, 200, new Vector2(8, 8), true, false, _idleAnim.CurrentFrame);
            _hitAnim.Play();

            gunLoop = AudioController.CreateInstance("minigun");
            gunLoop.IsLooped = true;
            gunLoop.Volume = 0f;
            gunLoop.Play();
            gunLoop.Pause();

            Speed.X = Helper.Random.Next(2) == 0 ? -0.1f : 0.1f;
        }
Exemple #28
0
        public Turret(Texture2D spritesheet, Rectangle hitbox, List <Vector2> hitPolyPoints, Vector2 hitboxoffset)
            : base(spritesheet, hitbox, hitPolyPoints, hitboxoffset)
        {
            _idleAnim = new SpriteAnim(spritesheet, 4, 2, 16, 16, 200, new Vector2(8, 8), true, false, 0);
            _idleAnim.Play();
            _hitAnim = new SpriteAnim(spritesheet, 10, 2, 16, 16, 200, new Vector2(8, 8), true, false, _idleAnim.CurrentFrame);
            _hitAnim.Play();

            gunLoop          = AudioController.CreateInstance("minigun");
            gunLoop.IsLooped = true;
            gunLoop.Volume   = 0f;
            gunLoop.Play();
            gunLoop.Pause();

            Speed.X = Helper.Random.Next(2) == 0 ? -0.1f : 0.1f;
        }
Exemple #29
0
            private static System.Collections.IEnumerator CoPerformKillFixed(KillAnimation __instance,
                                                                             PlayerControl source, PlayerControl target)
            {
                FollowerCamera cam           = Camera.main.GetComponent <FollowerCamera>();
                bool           isParticipant = PlayerControl.LocalPlayer == source || PlayerControl.LocalPlayer == target;
                PlayerPhysics  sourcePhys    = source.MyPhysics;

                KillAnimation.SetMovement(source, false);
                KillAnimation.SetMovement(target, false);
                if (isParticipant)
                {
                    cam.Locked = true;
                }

                target.Die(DeathReason.Kill);
                //We spawn dead body before WaitForAnimationFinish, to prevent having delay before the body spawns, while the target is already dead
                DeadBody deadBody = Object.Instantiate <DeadBody>(__instance.bodyPrefab);
                Vector3  vector   = target.transform.position + __instance.BodyOffset;

                vector.z = vector.y / 1000f;
                deadBody.transform.position = vector;
                deadBody.ParentId           = target.PlayerId;
                target.SetPlayerMaterialColors(deadBody.GetComponent <Renderer>());
                //
                SpriteAnim sourceAnim = source.GetComponent <SpriteAnim>();

                yield return(new WaitForAnimationFinish(sourceAnim, __instance.BlurAnim));

                source.NetTransform.SnapTo(target.transform.position);
                sourceAnim.Play(sourcePhys.IdleAnim, 1f);
                KillAnimation.SetMovement(source, true);
                //
                KillAnimation.SetMovement(target, true);
                if (isParticipant)
                {
                    cam.Locked = false;
                }

                yield break;
            }
Exemple #30
0
        public Ship(Texture2D spritesheet, Rectangle hitbox, List <Vector2> hitPolyPoints, Vector2 hitboxoffset)
            : base(spritesheet, hitbox, hitPolyPoints, hitboxoffset)
        {
            Instance = this;

            engineLoop          = AudioController.CreateInstance("boost");
            engineLoop.Volume   = 0f;
            engineLoop.IsLooped = true;
            engineLoop.Play();
            engineLoop.Pause();
            engineLoop.Volume = 0.3f;
            gunLoop           = AudioController.CreateInstance("minigun");
            gunLoop.IsLooped  = true;
            gunLoop.Volume    = 0f;
            gunLoop.Play();
            gunLoop.Pause();
            gunLoop.Volume   = 0.3f;
            hitLoop          = AudioController.CreateInstance("shiphit");
            hitLoop.IsLooped = false;
            hitLoop.Volume   = 1f;


            _idleAnim = new SpriteAnim(spritesheet, 0, 1, 16, 16, 100, new Vector2(8, 8));
            _idleAnim.Play();
            _upAnim = new SpriteAnim(spritesheet, 1, 2, 16, 16, 500, new Vector2(8, 8), false, false, 0);
            _upAnim.Pause();
            _downAnim = new SpriteAnim(spritesheet, 2, 2, 16, 16, 500, new Vector2(8, 8), false, false, 0);
            _downAnim.Pause();

            _idleHitAnim = new SpriteAnim(spritesheet, 3, 1, 16, 16, 100, new Vector2(8, 8));
            _idleHitAnim.Play();
            _upHitAnim = new SpriteAnim(spritesheet, 4, 2, 16, 16, 500, new Vector2(8, 8), false, false, 0);
            _upHitAnim.Pause();
            _downHitAnim = new SpriteAnim(spritesheet, 5, 2, 16, 16, 500, new Vector2(8, 8), false, false, 0);
            _downHitAnim.Pause();

            Active = true;
        }
Exemple #31
0
        public Ship(Texture2D spritesheet, Rectangle hitbox, List<Vector2> hitPolyPoints, Vector2 hitboxoffset)
            : base(spritesheet, hitbox, hitPolyPoints, hitboxoffset)
        {
            Instance = this;

            engineLoop = AudioController.CreateInstance("boost");
            engineLoop.Volume = 0f;
            engineLoop.IsLooped = true;
            engineLoop.Play();
            engineLoop.Pause();
            engineLoop.Volume = 0.3f;
            gunLoop = AudioController.CreateInstance("minigun");
            gunLoop.IsLooped = true;
            gunLoop.Volume = 0f;
            gunLoop.Play();
            gunLoop.Pause();
            gunLoop.Volume = 0.3f;
            hitLoop = AudioController.CreateInstance("shiphit");
            hitLoop.IsLooped = false;
            hitLoop.Volume = 1f;

            _idleAnim = new SpriteAnim(spritesheet, 0, 1, 16, 16, 100, new Vector2(8, 8));
            _idleAnim.Play();
            _upAnim = new SpriteAnim(spritesheet, 1, 2, 16, 16, 500, new Vector2(8, 8), false, false, 0);
            _upAnim.Pause();
            _downAnim = new SpriteAnim(spritesheet, 2, 2, 16, 16, 500, new Vector2(8, 8), false, false, 0);
            _downAnim.Pause();

            _idleHitAnim = new SpriteAnim(spritesheet, 3, 1, 16, 16, 100, new Vector2(8, 8));
            _idleHitAnim.Play();
            _upHitAnim = new SpriteAnim(spritesheet, 4, 2, 16, 16, 500, new Vector2(8, 8), false, false, 0);
            _upHitAnim.Pause();
            _downHitAnim = new SpriteAnim(spritesheet, 5, 2, 16, 16, 500, new Vector2(8, 8), false, false, 0);
            _downHitAnim.Pause();

            Active = true;
        }
Exemple #32
0
 public void NormalEnter()
 {
     animator.Play(walkingAnim);
 }
Exemple #33
0
 public void RisingStart()
 {
     animator.Play(riseAnim);
 }
        public bool PreBuild(MapAsset asset)
        {
            if (!asset.type.StartsWith("util-vent"))
            {
                return(true);
            }
            UtilData utilData = AssetDB.utils[asset.type];

            // Object
            GameObject obj = new GameObject(asset.type);

            // Sprite Renderer
            SpriteRenderer spriteRenderer = obj.AddComponent <SpriteRenderer>();

            spriteRenderer.sprite   = utilData.SpriteRenderer.sprite;
            spriteRenderer.material = utilData.SpriteRenderer.material;
            obj.layer = (int)Layer.ShortObjects;

            // Animator (If Applicable)
            if (asset.type == "util-vent1")
            {
                SpriteAnim spriteAnimClone = utilData.GameObj.GetComponent <SpriteAnim>();
                SpriteAnim spriteAnim      = obj.AddComponent <SpriteAnim>();

                spriteAnim.Play(spriteAnimClone.m_defaultAnim, spriteAnimClone.Speed);
                //spriteAnim.m_clipPairList = spriteAnimClone.m_clipPairList;
            }


            // Vent
            Vent ventData = utilData.GameObj.GetComponent <Vent>();
            Vent vent     = obj.AddComponent <Vent>();

            vent.EnterVentAnim = ventData.EnterVentAnim;
            vent.ExitVentAnim  = ventData.ExitVentAnim;
            vent.spreadAmount  = ventData.spreadAmount;
            vent.spreadShift   = ventData.spreadShift;
            vent.Offset        = ventData.Offset;
            vent.myRend        = spriteRenderer;
            vent.Buttons       = new UnhollowerBaseLib.Il2CppReferenceArray <ButtonBehavior>(0);
            vent.Id            = this.id;
            this.id++;

            // Arrow Buttons
            GameObject     arrowClone       = utilData.GameObj.transform.FindChild("Arrow").gameObject;
            SpriteRenderer arrowCloneSprite = arrowClone.GetComponent <SpriteRenderer>();
            BoxCollider2D  arrowCloneBox    = arrowClone.GetComponent <BoxCollider2D>();

            for (int i = 0; i < asset.targetIds.Length && i < 3; i++)
            {
                long targetId = asset.targetIds[i];
                if (targetId < 0)
                {
                    continue;
                }
                if (MapHandler.GetById(targetId) == null)
                {
                    continue;
                }

                GameObject arrowObj = new GameObject("Arrow" + targetId);

                // Sprite
                SpriteRenderer arrowSprite = arrowObj.AddComponent <SpriteRenderer>();
                arrowSprite.sprite   = arrowCloneSprite.sprite;
                arrowSprite.material = arrowCloneSprite.material;
                arrowObj.layer       = (int)Layer.UI;

                // Box Collider
                BoxCollider2D arrowBox = arrowObj.AddComponent <BoxCollider2D>();
                arrowBox.size      = arrowCloneBox.size;
                arrowBox.offset    = arrowCloneBox.offset;
                arrowBox.isTrigger = true;

                // Button
                ButtonBehavior arrowBtn = arrowObj.AddComponent <ButtonBehavior>();
                arrowBtn.OnMouseOver = new UnityEvent();
                arrowBtn.OnMouseOut  = new UnityEvent();
                Action action;
                if (i == 0)
                {
                    action = vent.ClickRight;
                }
                else if (i == 1)
                {
                    action = vent.ClickLeft;
                }
                else
                {
                    action = vent.ClickCenter;
                }
                arrowBtn.OnClick.AddListener(action);

                // Transform
                vent.Buttons = AssetHelper.AddToArr(vent.Buttons, arrowBtn);
                arrowObj.transform.SetParent(obj.transform);
                arrowObj.transform.localScale = new Vector3(0.4f, 0.4f, 1.0f);
                arrowObj.active = false;
            }

            // Box Collider
            BoxCollider2D origBox = utilData.GameObj.GetComponent <BoxCollider2D>();
            BoxCollider2D box     = obj.AddComponent <BoxCollider2D>();

            box.size      = origBox.size;
            box.offset    = origBox.offset;
            box.isTrigger = true;

            // Colliders
            AssetHelper.BuildColliders(asset, obj);

            // Polus
            ventDb.Add(asset.id, vent);
            targetDb.Add(asset.id, asset.targetIds);
            polus.shipStatus.AllVents = AssetHelper.AddToArr(polus.shipStatus.AllVents, vent);
            polus.Add(obj, asset);

            // Sounds
            if (!hasSounds)
            {
                polus.shipStatus.VentEnterSound = AssetDB.ss["ss-skeld"].ShipStatus.VentEnterSound;
                polus.shipStatus.VentMoveSounds = AssetDB.ss["ss-skeld"].ShipStatus.VentMoveSounds;
                hasSounds = true;
            }

            return(true);
        }
Exemple #35
0
        public override void HandleInput(InputState input)
        {
            if (!Active)
            {
                return;
            }

            Speed.X = MathHelper.Lerp(Speed.X, 0f, 0.01f);
            Speed.Y = MathHelper.Lerp(Speed.Y, 0f, 0.01f);

            Rectangle particleRect = underWater ? new Rectangle(128, 0, 16, 16) : new Rectangle(0, 0, 3, 3);

            engineLoop.Pause();

            if (input.CurrentKeyboardState.IsKeyDown(Keys.Left) ||
                input.CurrentKeyboardState.IsKeyDown(Keys.A) ||
                input.CurrentGamePadState.ThumbSticks.Left.X < -0.2f)
            {
                Speed.X -= 0.05f;
                faceDir  = -1;
                if (!underWater)
                {
                    ParticleController.Instance.Add(Position + new Vector2(5f, 0f),
                                                    new Vector2(Helper.RandomFloat(0f, 1f), Helper.RandomFloat(-0.2f, 0.2f)),
                                                    0, Helper.RandomFloat(500, 1000), 500,
                                                    false, true,
                                                    particleRect,
                                                    new Color(new Vector3(1f) * (0.5f + Helper.RandomFloat(0.5f))),
                                                    ParticleFunctions.Smoke,
                                                    underWater ? 0.3f : 1f, 0f, Helper.RandomFloat(-0.1f, 0.1f), 0, ParticleBlend.Alpha);
                }
                ParticleController.Instance.Add(Position + new Vector2(5f, 0f),
                                                new Vector2(Helper.RandomFloat(0f, 0.2f), Helper.RandomFloat(-0.2f, 0.2f)),
                                                0, underWater ? Helper.RandomFloat(500, 1000) : Helper.RandomFloat(50, 150), 50,
                                                false, true,
                                                particleRect,
                                                underWater ? Color.White : Color.Orange,
                                                ParticleFunctions.FadeInOut,
                                                underWater ? 0.3f : 1f, 0f, Helper.RandomFloat(-0.1f, 0.1f), 0, ParticleBlend.Alpha);

                engineLoop.Resume();
            }
            if (input.CurrentKeyboardState.IsKeyDown(Keys.Right) ||
                input.CurrentKeyboardState.IsKeyDown(Keys.D) ||
                input.CurrentGamePadState.ThumbSticks.Left.X > 0.2f)
            {
                Speed.X += 0.05f;
                faceDir  = 1;
                if (!underWater)
                {
                    ParticleController.Instance.Add(Position + new Vector2(-5f, 0f),
                                                    new Vector2(Helper.RandomFloat(0f, -1f), Helper.RandomFloat(-0.2f, 0.2f)),
                                                    0, Helper.RandomFloat(500, 1000), 500,
                                                    false, true,
                                                    particleRect,
                                                    new Color(new Vector3(1f) * (0.5f + Helper.RandomFloat(0.5f))),
                                                    ParticleFunctions.Smoke,
                                                    underWater ? 0.3f : 1f, 0f, Helper.RandomFloat(-0.1f, 0.1f), 0, ParticleBlend.Alpha);
                }
                ParticleController.Instance.Add(Position + new Vector2(-5f, 0f),
                                                new Vector2(Helper.RandomFloat(0f, -0.2f), Helper.RandomFloat(-0.2f, 0.2f)),
                                                0, underWater ? Helper.RandomFloat(500, 1000) : Helper.RandomFloat(50, 150), 50,
                                                false, true,
                                                particleRect,
                                                underWater ? Color.White : Color.Orange,
                                                ParticleFunctions.FadeInOut,
                                                underWater ? 0.3f : 1f, 0f, Helper.RandomFloat(-0.1f, 0.1f), 0, ParticleBlend.Alpha);

                engineLoop.Resume();
            }

            _idleAnim.CurrentFrame = 0;
            if (input.CurrentKeyboardState.IsKeyDown(Keys.Up) ||
                input.CurrentKeyboardState.IsKeyDown(Keys.W) ||
                input.CurrentGamePadState.ThumbSticks.Left.Y > 0.2f)
            {
                Speed.Y -= 0.05f;
                _upAnim.Play();
                _upHitAnim.Play();
                if (!underWater)
                {
                    ParticleController.Instance.Add(Position + new Vector2(0f, 3f),
                                                    new Vector2(Helper.RandomFloat(-0.3f, 0.3f), Helper.RandomFloat(0f, 1f)),
                                                    0, Helper.RandomFloat(500, 1000), 500,
                                                    false, true,
                                                    particleRect,
                                                    new Color(new Vector3(1f) * (0.5f + Helper.RandomFloat(0.5f))),
                                                    ParticleFunctions.Smoke,
                                                    underWater ? 0.3f : 1f, 0f, Helper.RandomFloat(-0.1f, 0.1f), 0, ParticleBlend.Alpha);
                }
                ParticleController.Instance.Add(Position + new Vector2(0f, 3f),
                                                new Vector2(Helper.RandomFloat(-0.3f, 0.3f), Helper.RandomFloat(0f, 0.2f)),
                                                0, underWater ? Helper.RandomFloat(500, 1000) : Helper.RandomFloat(50, 150), 50,
                                                false, true,
                                                particleRect,
                                                underWater ? Color.White : Color.Orange,
                                                ParticleFunctions.FadeInOut,
                                                underWater ? 0.2f : 0.75f, 0f, Helper.RandomFloat(-0.1f, 0.1f), 0, ParticleBlend.Alpha);

                engineLoop.Resume();
            }
            else
            {
                _upAnim.Reset();
                _upHitAnim.Reset();
            }
            if (input.CurrentKeyboardState.IsKeyDown(Keys.Down) ||
                input.CurrentKeyboardState.IsKeyDown(Keys.S) ||
                input.CurrentGamePadState.ThumbSticks.Left.Y < -0.2f)
            {
                Speed.Y += 0.05f;
                _downAnim.Play();
                _downHitAnim.Play();
                if (!underWater)
                {
                    ParticleController.Instance.Add(Position + new Vector2(0f, -3f),
                                                    new Vector2(Helper.RandomFloat(-0.3f, 0.3f), Helper.RandomFloat(0f, -1f)),
                                                    0, Helper.RandomFloat(500, 1000), 500,
                                                    false, true,
                                                    particleRect,
                                                    new Color(new Vector3(1f) * (0.5f + Helper.RandomFloat(0.5f))),
                                                    ParticleFunctions.Smoke,
                                                    underWater ? 0.3f : 1f, 0f, Helper.RandomFloat(-0.1f, 0.1f), 0, ParticleBlend.Alpha);
                }
                ParticleController.Instance.Add(Position + new Vector2(0f, -3f),
                                                new Vector2(Helper.RandomFloat(-0.3f, 0.3f), Helper.RandomFloat(0f, -0.2f)),
                                                0, underWater ? Helper.RandomFloat(500, 1000) : Helper.RandomFloat(50, 150), 50,
                                                false, true,
                                                particleRect,
                                                underWater ? Color.White : Color.Orange,
                                                ParticleFunctions.FadeInOut,
                                                underWater ? 0.2f : 0.75f, 0f, Helper.RandomFloat(-0.1f, 0.1f), 0, ParticleBlend.Alpha);

                engineLoop.Resume();
            }
            else
            {
                _downAnim.Reset();
                _downHitAnim.Reset();
            }



            if (input.CurrentKeyboardState.IsKeyDown(Keys.X) ||
                input.CurrentKeyboardState.IsKeyDown(Keys.Space) ||
                input.CurrentGamePadState.Buttons.A == ButtonState.Pressed ||
                input.CurrentGamePadState.Triggers.Right > 0.2f)
            {
                if (projectileTime1 <= 0)
                {
                    projectileTime1 = projectileCoolDown1;


                    if (PowerUpLevel != 1)
                    {
                        ProjectileController.Instance.Spawn(entity =>
                        {
                            ((Projectile)entity).Type       = ProjectileType.Forward1;
                            ((Projectile)entity).SourceRect = new Rectangle(8, 8, 20, 8);
                            ((Projectile)entity).Life       = 1000;
                            ((Projectile)entity).EnemyOwner = false;
                            ((Projectile)entity).Damage     = 1f;
                            entity.Speed    = new Vector2(6f * faceDir, 0f);
                            entity.Position = Position + new Vector2(faceDir * 10, 0);
                        });
                    }

                    if (PowerUpLevel == 1)
                    {
                        ProjectileController.Instance.Spawn(entity =>
                        {
                            ((Projectile)entity).Type       = ProjectileType.Forward1;
                            ((Projectile)entity).SourceRect = new Rectangle(8, 8, 20, 8);
                            ((Projectile)entity).Life       = 1000;
                            ((Projectile)entity).EnemyOwner = false;
                            ((Projectile)entity).Damage     = 1f;
                            entity.Speed    = new Vector2(6f * faceDir, 0f);
                            entity.Position = Position + new Vector2(faceDir * 10, -2);
                        });
                        ProjectileController.Instance.Spawn(entity =>
                        {
                            ((Projectile)entity).Type       = ProjectileType.Forward1;
                            ((Projectile)entity).SourceRect = new Rectangle(8, 8, 20, 8);
                            ((Projectile)entity).Life       = 1000;
                            ((Projectile)entity).EnemyOwner = false;
                            ((Projectile)entity).Damage     = 1f;
                            entity.Speed    = new Vector2(6f * faceDir, 0f);
                            entity.Position = Position + new Vector2(faceDir * 10, 2);
                        });
                    }

                    if (PowerUpLevel >= 2)
                    {
                        ProjectileController.Instance.Spawn(entity =>
                        {
                            ((Projectile)entity).Type       = ProjectileType.Forward1;
                            ((Projectile)entity).SourceRect = new Rectangle(8, 8, 20, 8);
                            ((Projectile)entity).Life       = 1000;
                            ((Projectile)entity).EnemyOwner = false;
                            ((Projectile)entity).Damage     = 1f;
                            entity.Speed    = new Vector2(6f * faceDir, -0.5f);
                            entity.Position = Position + new Vector2(faceDir * 10, 0);
                        });
                        ProjectileController.Instance.Spawn(entity =>
                        {
                            ((Projectile)entity).Type       = ProjectileType.Forward1;
                            ((Projectile)entity).SourceRect = new Rectangle(8, 8, 20, 8);
                            ((Projectile)entity).Life       = 1000;
                            ((Projectile)entity).EnemyOwner = false;
                            ((Projectile)entity).Damage     = 1f;
                            entity.Speed    = new Vector2(6f * faceDir, 0.5f);
                            entity.Position = Position + new Vector2(faceDir * 10, 0);
                        });
                    }
                }

                if (projectileTime2 <= 0)
                {
                    projectileTime2 = projectileCoolDown2;

                    if (PowerUpLevel >= 3)
                    {
                        ProjectileController.Instance.Spawn(entity =>
                        {
                            ((Projectile)entity).Type       = ProjectileType.Bomb;
                            ((Projectile)entity).SourceRect = new Rectangle(16, 0, 8, 8);
                            ((Projectile)entity).Life       = 5000;
                            ((Projectile)entity).Scale      = 0.5f;
                            ((Projectile)entity).EnemyOwner = false;
                            ((Projectile)entity).Damage     = 20f;
                            entity.Speed    = new Vector2(1f * faceDir, 0f);
                            entity.Position = Position + new Vector2(0, 5);
                        });
                    }
                }

                if (projectileTime3 <= 0)
                {
                    projectileTime3 = projectileCoolDown3;

                    if (PowerUpLevel >= 4)
                    {
                        AudioController.PlaySFX("seeker", 0.5f, -0.1f, 0.1f);

                        ProjectileController.Instance.Spawn(entity =>
                        {
                            ((Projectile)entity).Type       = ProjectileType.Seeker;
                            ((Projectile)entity).SourceRect = new Rectangle(1, 18, 8, 4);
                            ((Projectile)entity).Life       = 3000;
                            ((Projectile)entity).Scale      = 1f;
                            ((Projectile)entity).EnemyOwner = false;
                            ((Projectile)entity).Damage     = 5f;
                            ((Projectile)entity).Target     = Position + new Vector2(faceDir * 300, 0);
                            ;
                            entity.Speed    = new Vector2(0f, -0.5f);
                            entity.Position = Position + new Vector2(0, 0);
                        });
                    }
                }

                isFiring = true;
                gunLoop.Resume();
            }
            else if (isFiring)
            {
                isFiring = false;
                gunLoop.Pause();
                AudioController.PlaySFX("gun_winddown", gunLoop.Volume, -0.1f, 0.1f);
            }

            base.HandleInput(input);
        }