コード例 #1
0
    public void UpdateSeedState(SeedState state)
    {
        State = state;

        switch (State)
        {
        case SeedState.ForSale:
            gameObject.SetActive(true);

            break;

        case SeedState.InInventory:
            gameObject.SetActive(false);

            break;

        case SeedState.InHand:
            gameObject.SetActive(true);

            break;

        case SeedState.Planted:

            break;

        case SeedState.Discarded:
            gameObject.SetActive(true);

            break;
        }
    }
コード例 #2
0
ファイル: AbilitiesMenuHook.cs プロジェクト: nikitaosyak/ld32
        void Update()
        {
            if (bombCooldown < Time.timeSinceLevelLoad)
            {
                bombCooldown            = float.MaxValue;
                bombState               = BombState.WAITING;
                bombButtonText.text     = "Bomb ready";
                bombButton.interactable = true;
            }
            else
            if (bombCooldown != float.MaxValue)
            {
                bombButtonText.text = ((int)(bombCooldown - Time.timeSinceLevelLoad)).ToString();
            }

            if (seedCooldown < Time.timeSinceLevelLoad)
            {
                seedCooldown            = float.MaxValue;
                seedState               = SeedState.WAITING;
                seedButtonText.text     = "Seed ready";
                seedButton.interactable = true;
            }
            else
            if (seedCooldown != float.MaxValue)
            {
                seedButtonText.text = ((int)(seedCooldown - Time.timeSinceLevelLoad)).ToString();
            }
        }
コード例 #3
0
ファイル: AbilitiesMenuHook.cs プロジェクト: nikitaosyak/ld32
        public void onSeedDeployed()
        {
            if (firstSeedDeploy)
            {
                var au = Camera.main.GetComponents <AudioSource>();
                foreach (var a in au)
                {
                    if (a.clip.name != "music")
                    {
                        a.Stop();
                    }
                    if (a.clip.name == "deploy_seed_launched")
                    {
                        a.Play();
                    }
                }
                firstSeedDeploy = false;
            }
            _sim.attachToDrag3(null);
            _seedTargetInstance.transform.position = new Vector3(-100f, 100f);

            seedCooldown            = Time.timeSinceLevelLoad + 6f;
            seedState               = SeedState.RECHARGE;
            seedButtonText.text     = "Charging";
            seedButton.interactable = false;
        }
コード例 #4
0
 public SeedImpl(SeedType st)
 {
     this.st          = st;
     this.ss          = SeedState.PLANTED;
     this.growTime    = SeedTypeMethods.GetGrowTime(st);
     this.ofWhichFood = SeedTypeMethods.GetFoodType(st);
     WaitGrow();
 }
コード例 #5
0
        /// <summary>
        /// Updates the seed ship. Ship will move towards the Player and fire bullets when it is close.
        /// </summary>
        /// <param name="elapsedTime">Time since last update.</param>
        public override void Update(float elapsedTime)
        {
            _timer += elapsedTime;

            //Move towards the Player.
            PlayerShip Player         = ScrollingShooterGame.Game.Player;
            Vector2    PlayerPosition = new Vector2(Player.Bounds.Center.X, Player.Bounds.Center.Y);
            Vector2    toPlayer       = PlayerPosition - this._position;

            this._position += toPlayer * (float)((double)elapsedTime * .5);

            switch (_state)
            {
            case SeedState.Closed:
                if (toPlayer.LengthSquared() < 9000)
                {
                    //Close enough, start opening.
                    _timer   = 0f;
                    _opening = true;
                    _state   = SeedState.Opening;
                }
                break;

            case SeedState.Opening:
                if (_timer >= STATE_TIME)
                {
                    //Ready to open or close.
                    _state = (_opening) ? SeedState.Open : SeedState.Closed;
                    _timer = 0f;
                }
                break;

            case SeedState.Open:
                //Fire bullets until we have fired 5 bullets.
                if (firedBullets < NUM_OF_BULLETS_PER_FIRE && _timer >= FIRE_TIME)
                {
                    ScrollingShooterGame.GameObjectManager.CreateProjectile(ProjectileType.ToPlayerBullet, _position);
                    firedBullets++;
                }
                else if (firedBullets == NUM_OF_BULLETS_PER_FIRE)
                {
                    //Reset bullet count and start closing.
                    firedBullets = 0;
                    _timer       = 0f;
                    _opening     = false;
                    _state       = SeedState.Opening;
                }
                break;

            case SeedState.Destroyed:
                //Do nothing for now.
                break;

            default:
                throw new Exception("Unknown state!");
            }
        }
コード例 #6
0
    void ActivateState(int state)
    {
        // Disable the old state if we have one
        if (m_ActiveState != null)
        {
            if (popOnStateChange)
            {
                Instantiate(popEffect, m_ActiveState.visuals.transform.position, Quaternion.identity);
            }
            m_ActiveState.visuals.SetActive(false);
        }

        m_ActiveState = m_States[state];
        anim          = m_ActiveState.visuals.GetComponent <Animator>();
        m_ActiveState.visuals.SetActive(true);
    }
コード例 #7
0
    private void Start()
    {
        for (int i = 0; i < transform.childCount; ++i)
        {
            transform.GetChild(i).gameObject.SetActive(false);
        }


        //anim.SetInteger("FlowerForm", startingBloomState);
        anim           = GetComponentInChildren <Animator>();
        m_CurrentState = 0;
        m_ActiveState  = null;
        ActivateState(m_CurrentState);

        switch (startingBloomState)
        {
        case 0:
            bloomState = BloomStates.Seed;
            break;

        case 1:
            bloomState = BloomStates.Bud;
            break;

        case 2:
            bloomState = BloomStates.Bloom;
            break;

        default:
            break;
        }

        //BloomStateOneFrameChecks();

        SeedColliderOffset = new Vector2(0, 0);
        seedColliderHeight = new Vector2(1, 1.5f);
    }
コード例 #8
0
ファイル: AbilitiesMenuHook.cs プロジェクト: nikitaosyak/ld32
        public void onSeedClick()
        {
            if (firstSeedClick)
            {
                var au = Camera.main.GetComponents <AudioSource>();
                foreach (var a in au)
                {
                    if (a.clip.name != "music")
                    {
                        a.Stop();
                    }
                    if (a.clip.name == "deploy_seed_hint")
                    {
                        a.Play();
                    }
                }
                firstSeedClick = false;
            }
            switch (seedState)
            {
            case SeedState.WAITING:
                seedButtonText.text = "Cancel deploy";
                seedState           = SeedState.SEED_DEPLOY;
                _sim.attachToDrag3(_seedTargetInstance);
                break;

            case SeedState.SEED_DEPLOY:
                seedButtonText.text = "Seed ready";
                seedState           = SeedState.WAITING;
                _sim.attachToDrag3(null);
                _seedTargetInstance.transform.position = new Vector3(-100f, 100f);
                break;

            case SeedState.RECHARGE:
                break;
            }
        }
コード例 #9
0
ファイル: AbilitiesMenuHook.cs プロジェクト: andi2/ld32-6
        void Update()
        {
            if (bombCooldown < Time.timeSinceLevelLoad)
            {
                bombCooldown = float.MaxValue;
                bombState = BombState.WAITING;
                bombButtonText.text = "Bomb ready";
                bombButton.interactable = true;
            }
            else
            if (bombCooldown != float.MaxValue)
            {
                bombButtonText.text = ((int)(bombCooldown - Time.timeSinceLevelLoad)).ToString();
            }

            if (seedCooldown < Time.timeSinceLevelLoad)
            {
                seedCooldown = float.MaxValue;
                seedState = SeedState.WAITING;
                seedButtonText.text = "Seed ready";
                seedButton.interactable = true;
            }
            else
            if (seedCooldown != float.MaxValue)
            {
                seedButtonText.text = ((int)(seedCooldown - Time.timeSinceLevelLoad)).ToString();
            }
        }
コード例 #10
0
ファイル: AbilitiesMenuHook.cs プロジェクト: andi2/ld32-6
        public void onSeedDeployed()
        {
            if (firstSeedDeploy)
            {
                var au = Camera.main.GetComponents<AudioSource>();
                foreach (var a in au)
                {
                    if (a.clip.name != "music")
                    {
                        a.Stop();
                    }
                    if (a.clip.name == "deploy_seed_launched")
                    {
                        a.Play();
                    }
                }
                firstSeedDeploy = false;
            }
            _sim.attachToDrag3(null);
            _seedTargetInstance.transform.position = new Vector3(-100f, 100f);

            seedCooldown = Time.timeSinceLevelLoad + 6f;
            seedState = SeedState.RECHARGE;
            seedButtonText.text = "Charging";
            seedButton.interactable = false;
        }
コード例 #11
0
ファイル: AbilitiesMenuHook.cs プロジェクト: andi2/ld32-6
 public void onSeedClick()
 {
     if (firstSeedClick)
     {
         var au = Camera.main.GetComponents<AudioSource>();
         foreach (var a in au)
         {
             if (a.clip.name != "music")
             {
                 a.Stop();
             }
             if (a.clip.name == "deploy_seed_hint")
             {
                 a.Play();
             }
         }
         firstSeedClick = false;
     }
     switch(seedState)
     {
     case SeedState.WAITING:
         seedButtonText.text = "Cancel deploy";
         seedState = SeedState.SEED_DEPLOY;
         _sim.attachToDrag3(_seedTargetInstance);
         break;
     case SeedState.SEED_DEPLOY:
         seedButtonText.text = "Seed ready";
         seedState = SeedState.WAITING;
         _sim.attachToDrag3(null);
         _seedTargetInstance.transform.position = new Vector3(-100f, 100f);
         break;
     case SeedState.RECHARGE:
         break;
     }
 }
コード例 #12
0
ファイル: Seed.cs プロジェクト: barge5633/scrolling-shooter
        /// <summary>
        /// Updates the seed ship. Ship will move towards the player and fire bullets when it is close.
        /// </summary>
        /// <param name="elapsedTime">Time since last update.</param>
        public override void Update(float elapsedTime)
        {
            _timer += elapsedTime;

            //Move towards the player.
            PlayerShip player = ScrollingShooterGame.Game.player;
            Vector2 playerPosition = new Vector2(player.Bounds.Center.X, player.Bounds.Center.Y);
            Vector2 toPlayer = playerPosition - this._position;
            this._position += toPlayer * (float)((double)elapsedTime * .5);

            switch (_state)
            {
                case SeedState.Closed:
                    if (toPlayer.LengthSquared() < 9000)
                    {
                        //Close enough, start opening.
                        _timer = 0f;
                        _opening = true;
                        _state = SeedState.Opening;
                    }
                    break;
                case SeedState.Opening:
                    if (_timer >= STATE_TIME)
                    {
                        //Ready to open or close.
                        _state = (_opening) ? SeedState.Open : SeedState.Closed;
                        _timer = 0f;
                    }
                    break;
                case SeedState.Open:
                    //Fire bullets until we have fired 5 bullets.
                    if (firedBullets < NUM_OF_BULLETS_PER_FIRE && _timer >= FIRE_TIME)
                    {
                        ScrollingShooterGame.GameObjectManager.CreateProjectile(ProjectileType.ToPlayerBullet, _position);
                        firedBullets++;
                    }
                    else if (firedBullets == NUM_OF_BULLETS_PER_FIRE)
                    {
                        //Reset bullet count and start closing.
                        firedBullets = 0;
                        _timer = 0f;
                        _opening = false;
                        _state = SeedState.Opening;
                    }
                    break;
                case SeedState.Destroyed:
                    //Do nothing for now.
                    break;
                default:
                    throw new Exception("Unknown state!");
            }
        }
コード例 #13
0
 public FoodType Harvest()
 {
     this.ss = SeedState.HARVESTED;
     return(ofWhichFood);
 }
コード例 #14
0
 public void Grow()
 {
     this.ss = SeedState.GROWN;
 }