示例#1
0
    /// <summary>
    ///  Updates the appearance of the spirit
    /// </summary>
    public void UpdateSpiritAppearance(SpiritState spiritState)
    {
        switch (spiritState)
        {
        case SpiritState.None:
            this.spriteRenderer.sprite = this.noElementSprite;
            this.light2D.color         = this.noElement;
            break;

        case SpiritState.Air:
            this.spriteRenderer.sprite = this.airSprite;
            this.light2D.color         = this.air;
            break;

        case SpiritState.Fire:
            this.spriteRenderer.sprite = this.fireSprite;
            this.light2D.color         = this.fire;
            break;

        case SpiritState.Water:
            this.spriteRenderer.sprite = this.waterSprite;
            this.light2D.color         = this.water;
            break;

        case SpiritState.Earth:
            this.spriteRenderer.sprite = this.earthSprite;
            this.light2D.color         = this.earth;
            break;
        }
    }
示例#2
0
        public override void Update(GameTime gameTime)
        {
            GameObject.Position = ConvertUnits.ToDisplayUnits(_physics.Position);

            if (_physics.Velocity == Vector2.Zero)
            {
                State = SpiritState.SS_IDLE;
            }
            else
            {
                State = SpiritState.SS_MOVING;
                if (_physics.Velocity.X < 0)
                {
                    Facing = -1;
                }
                else
                {
                    Facing = 1;
                }
            }

            if (_oldState != State)
            {
                if (OnStateChange != null)
                {
                    OnStateChange(State);
                }
            }
            _oldState = State;
        }
示例#3
0
 private void onStateChanged(SpiritState state)
 {
     if (_isChangingForm == false)
     {
         if (state == SpiritState.SS_IDLE)
         {
             if (_currentForm == SpiritForm.SF_BALL)
             {
                 playAnimation(MovingAnimations[SpiritMovements.SM_BALLIDLE]);
             }
             else
             {
                 playAnimation(MovingAnimations[SpiritMovements.SM_IDLE]);
             }
         }
         else if (state == SpiritState.SS_MOVING)
         {
             if (_currentForm == SpiritForm.SF_SPIRIT)
             {
                 playAnimation(MovingAnimations[SpiritMovements.SM_MOVING]);
             }
             else if (_currentForm == SpiritForm.SF_CHASER)
             {
                 playAnimation(MovingAnimations[SpiritMovements.SM_CHASING]);
             }
         }
     }
 }
示例#4
0
    /// <summary>
    ///  Returns a copy of the cast spell
    /// </summary>
    /// <param name="elementOne"></param>
    /// <param name="elementTwo"></param>
    public Spell GetCopyOfSpell(SpiritState elementOne, SpiritState elementTwo)
    {
        var nextSpell = Instantiate(this.spells[elementOne][elementTwo]);

        nextSpell.gameObject.SetActive(true);

        return(nextSpell);
    }
        private bool StateChanged()
        {
            var currentState = this._spiritData.GetState();
            var changed      = prevSpiritState != currentState;

            this.prevSpiritState = currentState;

            return(changed);
        }
    private void SpiritWasCatched(SpiritState spiritState)
    {
        if (spiritState == SpiritState.CatchedAgressive)
        {
            Game.Instance.Player.Money += random.Next(30, 50);
            is_finished = true;
        }

        if (spiritState == SpiritState.CatchedPeaceful)
        {
            Game.Instance.Player.Money        += random.Next(30, 50);
            Game.Instance.Player.SpiritPoints += random.Next(5, 10);
            is_finished = true;
        }
    }
    private void CmdCreateSpell(SpiritState firstElement, SpiritState secondElement, Vector2 position, Vector2 orientation)
    {
        var spell = this.spells.GetCopyOfSpell(firstElement, secondElement);

        spell.playerPosition = position;
        spell.castDirection  = orientation;
        spell.caster         = this.GetComponent <NetworkIdentity>().netId;

        if (!spell.IsSpellInsideWall())
        {
            NetworkServer.Spawn(spell.gameObject);
        }
        else
        {
            Destroy(spell.gameObject);
        }
    }
示例#8
0
    void Start()
    {
        m_InputHandler       = GetComponent <InputHandler>();
        m_CreatureController = GetComponent <CreatureController>();

        m_Nest     = transform.parent.gameObject;
        m_NestXPos = m_Nest.transform.position.x;

        m_SpiritState  = new SpiritState(this);
        m_IdleState    = new IdleState(this);
        m_RoamingState = new RoamingState(this);

        m_CurrentState = m_IdleState;
        if (m_CurrentState != null && !m_InputHandler.PlayerControlled)
        {
            m_CurrentState.Enter();
        }
    }
示例#9
0
    private void Move()
    {
        timer += Time.deltaTime;

        if (timer >= 0.05f)
        {
            FOVRotation();
            timer = 0;
        }
        //spiritList = GameObject.FindGameObjectsWithTag("Spirit");
        switch (spiritState)
        {
        // travel between terminals
        case SpiritState.Idle:
            nav.destination = idleDest;
            break;

        // move towards the player
        case SpiritState.Attack:
            if (playerSpirit != null)
            {
                huntedPos = playerSpirit.transform.position;
            }
            else
            {
                spiritState = SpiritState.Idle;
                break;
            }
            nav.destination = huntedPos;
            break;

        // stand still???
        case SpiritState.Suspicious:
            nav.destination = transform.position;
            break;
        }
    }
示例#10
0
    void Start()
    {
        speaker          = GetComponent <AudioSource>();
        FOV              = GetComponentInChildren <SpiritView>().gameObject;
        nav              = GetComponent <NavMeshAgent2D>();
        rig              = GetComponent <Rigidbody2D>();
        emotions         = GetComponent <AnimationManager>();
        displayInventory = GetComponentInChildren <Text>();
        //inventory.text = "hi";
        // fill with terminals, for navigation between them
        terminalList = GameObject.FindGameObjectsWithTag("terminal");
        terminals.AddRange(terminalList);

        //sets initial random target terminal for spirits
        int i = UnityEngine.Random.Range(0, terminals.Count);

        previousPosition = i;
        idleDest         = terminals[i].transform.position;

        spiritState = SpiritState.Idle;

        ogTerminalWaitTime = terminalWaitTime;
        goldInventory      = UnityEngine.Random.Range(4, 7);
    }
示例#11
0
    public void IsAttacking()
    {
        spiritState = SpiritState.Attack;
        if (!screamed)
        {
            MusicMode musicSetting = (MusicMode)PlayerPrefs.GetInt("Music", 0);
            switch (musicSetting)
            {
            case MusicMode.FULL:
                speaker.volume = 1.0f;
                break;

            case MusicMode.MUTE:
                speaker.volume = 0f;
                break;

            case MusicMode.HALF:
                speaker.volume = 0.5f;
                break;
            }
            speaker.PlayOneShot(scream_sfx);
            screamed = true;
        }
    }
示例#12
0
 public void HandleStateChanged(SpiritState oldState, SpiritState newState) => spiritAnimationHandler.UpdateSpiritAppearance(this.state);
示例#13
0
 public void CmdUpdateState(SpiritState nextState)
 {
     this.state = nextState;
 }
示例#14
0
 public void IsIdle()
 {
     spiritState = SpiritState.Idle;
     screamed    = false;
 }
示例#15
0
 public void IsSuspicious()
 {
     spiritState = SpiritState.Suspicious;
     //emotions.SetEmotion(Emotions.SCARED);
 }