Exemple #1
0
        /*
         * Vixen event handler. Responds to selection events:
         *	Event.SELECT	shape picked in 3D scene
         *	Event.DESELECT	nothing picked in 3D scene
         *	Event.ENTER		3D object enters trigger area
         *	Calls the OnPick function to handle the selection.
         */
        public override void OnVixen(Event ev, SharedWorld world)
        {
            int code = ev.Code;

            if (code == Event.SELECT)
            {
                try
                {
                    PickEvent pe     = ev as PickEvent;
                    Shape     picked = pe.Target as Shape;
                    OnPick(picked);
                }
                catch (Exception) { }
            }
            else if (code == Event.ENTER)
            {
                try
                {
                    TriggerEvent te     = ev as TriggerEvent;
                    Shape        picked = te.Target as Shape;
                    OnPick(picked);
                }
                catch (Exception) { }
            }
            else if (code == Event.DESELECT)
            {
                OnPick(null);
            }
            base.OnVixen(ev, world);
        }
    private void SendAlternateRandomEvent()
    {
        this.m_StateActive         = true;
        this.m_AlternateEventState = true;
        List <int> list = new List <int>();

        if (this.m_AlternateState.Count == 1)
        {
            list.Add(0);
        }
        else
        {
            for (int i = 0; i < this.m_AlternateState.Count; i++)
            {
                if (i != this.m_LastAlternateIndex)
                {
                    list.Add(i);
                }
            }
        }
        int       num2   = UnityEngine.Random.Range(0, list.Count);
        PickEvent event2 = this.m_AlternateState[list[num2]];

        this.m_CurrentState           = event2;
        this.m_LastAlternateIndex     = list[num2];
        this.m_StartAnimationFinished = false;
        base.StartCoroutine(this.WaitForStartAnimation());
        event2.m_FSM.SendEvent(event2.m_StartEvent);
    }
 private void Awake()
 {
     this.m_Collider = base.GetComponent <Collider>();
     if (this.m_AwakeStateIndex > -1)
     {
         this.m_CurrentState   = this.m_State[this.m_AwakeStateIndex];
         this.m_LastEventIndex = this.m_AwakeStateIndex;
         this.m_StateActive    = true;
     }
 }
Exemple #4
0
    public void OnEvent(PickEvent _pickEvent)
    {
        if (_pickEvent.whoPicks.CharacterID.Equals("Spooky") == true)
        {
            if (_pickEvent.type == PickEventType.CornBag)
            {
                GiveCrop(_pickEvent.pickValue);
                UpdateCropUIBar();
            }
            else if (_pickEvent.type == PickEventType.EnemySoul)
            {
                GiveMoney(_pickEvent.pickValue);
                UpdateMoneyDisplay();
            }
        }

        return;
    }
Exemple #5
0
    // Pick & Shoot
    void OnPick()
    {
        if (!this.enabled)
        {
            return;
        }
        if (playerStatus.PlayerPick())
        {
            return;
        }
        if (IsHolding)
        {
            if (IsHolding && playerStatus.CanAnimation())
            {
                _playerItemStatus status = new _playerItemStatus();
                status.Throwing = IsThrowing2;
                string animation = itemHand.UseItem(status);
                if (animation == "Empty" || animation == "")
                {
                }
                else if (animation == "SetMine")
                {
                    SetMine();
                }
                else if (animation == "Axe")
                {
                    AnimatorClipInfo[] CurrentClipInfo;
                    CurrentClipInfo = playerStatus.animator.GetCurrentAnimatorClipInfo(1);
                    if (CurrentClipInfo[0].clip.name == "Twinblades_attack02_Inplace")
                    {
                    }
                    else
                    {
                        playerStatus.PlayerItemAnimation(animation);
                    }
                }
                else
                {
                    if (IsThrowing)
                    {
                        return;
                    }
                    if (animation[0] == '_')
                    {
                        IsCharging = true;
                        playerStatus.PlayerItemAnimationBool(animation, true);
                    }
                    else
                    {
                        playerStatus.PlayerItemAnimation(animation);
                    }
                }
            }

            /*playerStatus.PlayerItem_Aim();
             * IsThrowing = true;
             * IsThrowing2 = true;*/
        }
        else if (!IsHolding)
        {
            Collider[] colliders = Physics.OverlapSphere(transform.position, PickRadius);

            if (colliders.Length > 0)
            {
                float    shortestDistance = 10;
                Collider pick             = null;

                foreach (Collider collider in colliders)
                {
                    if (collider.gameObject.tag != "Item")
                    {
                        continue;
                    }
                    if (collider.gameObject.GetComponent <ItemBasic>().IsHolded)
                    {
                        continue;
                    }
                    if (pick == null)
                    {
                        pick             = collider;
                        shortestDistance = Vector3.Distance(this.gameObject.transform.position, pick.transform.position);
                    }
                    float distance = Vector3.Distance(this.gameObject.transform.position, pick.transform.position);
                    if (distance < shortestDistance)
                    {
                        pick             = collider;
                        shortestDistance = distance;
                    }
                }

                if (pick != null)
                {
                    IsHolding = true;
                    itemHand.SetHoldingItem(pick.gameObject);
                    PickEvent?.Invoke(pick.gameObject.GetComponent <ItemBasic>());
                    if (pick.gameObject.GetComponent <ItemBasic>().IdleAnimation != "")
                    {
                        playerStatus.PlayerItemAnimationBool(pick.gameObject.GetComponent <ItemBasic>().IdleAnimation, true);
                    }
                    GameObject g = Instantiate(PickUpParticle, transform.position, Quaternion.identity);
                    g.transform.parent = this.gameObject.transform;
                    Destroy(g, 1);
                }
            }
        }
    }
Exemple #6
0
 public static void OnPickEvent(CharacterMovement characterMovement)
 {
     PickEvent?.Invoke(characterMovement);
 }