Activate() абстрактный публичный Метод

abstract public Activate ( ) : void
Результат void
Пример #1
0
    private ActivationResult ApplyActivatable(Activatable activatable, Character instigator, ulong timestamp, bool extra)
    {
        if (activatable != null)
        {
            switch (this.activationMode)
            {
            case ActivationMode.TurnOn:
                return(activatable.Activate(true, instigator, timestamp));

            case ActivationMode.TurnOff:
                return(activatable.Activate(false, instigator, timestamp));
            }
            return(activatable.Activate(instigator, timestamp));
        }
        return(ActivationResult.Error_Destroyed);
    }
Пример #2
0
    protected override void Draw()
    {
        if (!drawingLastFrame)
        {
            startedTime = Time.time;
        }

        float moveFrac = (Time.time - startedTime) / duration;

        // don't move past the end point
        moveFrac = Mathf.Min(moveFrac, 1);

        target.transform.position = Vector2.Lerp(
            start.position,
            end.position,
            moveFrac
            );

        if (target.transform.position == end.position)
        {
            running = false;
            if (endCallback != null)
            {
                endCallback.Activate();
            }
        }
    }
Пример #3
0
    void Update()
    {
        //When player left clicks
        if (Input.GetMouseButtonDown(0))
        {
            //Raycast info
            RaycastHit hit;
            //it is important that the camera of the fps controller is tagged as: "MainCamera"
            Vector3 origin = Camera.main.transform.position;
            //we take the blue axis arrow (z-axis) as the direction we shoot the raycast into
            Vector3 direction = Camera.main.transform.forward;

            //Shoot a ray from camera along its z-axis
            if (Physics.Raycast(origin, direction, out hit, MaxDistance))
            {
                //The gameobject that was hit
                GameObject g = hit.collider.gameObject;
                if (g)
                {
                    //The activatable script that is attached to this gameobject
                    Activatable a = g.GetComponent <Activatable>();
                    if (a != null)
                    {
                        //if the object has a Activatable script, execute this
                        a.Activate();
                    }
                }
            }
        }
    }
Пример #4
0
 void RejectItems()
 {
     if (noActivation != null)
     {
         noActivation.Activate();
     }
 }
Пример #5
0
    // Update is called once per frame
    void Update()
    {
        if (!isLocalPlayer)
        {
            return;
        }

        activateUI.sprite = defaultSprite;
        Vector3 rayPos = gameObject.transform.position;
        //Ray ray = GameObject.FindGameObjectWithTag("SlaveCamera").GetComponent<Camera>().ScreenPointToRay(Input.mousePosition);
        Ray ray = new Ray(rayPos, gameObject.transform.forward);
        //RaycastHit[] hits = Physics.RaycastAll(ray);
        RaycastHit hit;

        if (Physics.SphereCast(ray, sphereRadius, out hit, castDistance, activatable))
        {
            hitDistance = hit.distance;
            Activatable act = hit.transform.GetComponent <Activatable>();
            if (act != null)
            {
                activateUI.sprite = act.image;
                if (Input.GetKeyDown(KeyCode.E))
                {
                    act.Activate();
                }
            }
        }
        else
        {
            hitDistance = castDistance;
        }
    }
Пример #6
0
 override public void ActivateSwitch(bool b)
 {
     if (b && Random.value > chance)
     {
         target.Activate();
     }
 }
 void onScoreChange(int amount)
 {
     if (amount == ActivationAmount)
     {
         activatable.Activate();
     }
 }
Пример #8
0
 private void OnTriggerEnter2D(Collider2D collision)
 {
     if (collision.tag == "Player")
     {
         activatable.Activate();
     }
 }
Пример #9
0
 public void OnTriggerEnter2D(Collider2D other)
 {
     if (other.tag == "Character" || other.tag == "Box")
     {
         Debug.Log("Plate pressured");
         activatable.Activate();
     }
 }
Пример #10
0
 private void OnTriggerEnter(Collider other)
 {
     if (other.gameObject.CompareTag("Ball"))
     {
         linked_object.Activate();
         GetComponent <AudioSource>().Play();
     }
 }
Пример #11
0
 void OnTimer()
 {
     if (LoopTimer || !TimerFinishedOnce)
     {
         activatable.Activate();
     }
     TimerFinishedOnce = true;
 }
Пример #12
0
    // TODO: have rena get up and walk off, then trigger this to remove her fight
    IEnumerator _FadeCallback()
    {
        GlobalController.ShortBlackFade();
        yield return(new WaitForSecondsRealtime(0.5f));

        if (target != null)
        {
            target.Activate();
        }
    }
Пример #13
0
 void OnTriggerEnter2D(Collider2D other)
 {
     foreach (string s in wantedTags)
     {
         if (other.gameObject.CompareTag(s))
         {
             activatable.Activate();
             return;
         }
     }
 }
Пример #14
0
 public virtual void OnPickup()
 {
     if (IsAbility())
     {
         GlobalController.abilityUIAnimator.GetComponent <AbilityGetUI>().GetItem(this);
         GlobalController.UnlockAbility(this.ability);
     }
     if (activatesOnPickup != null)
     {
         activatesOnPickup.Activate();
     }
 }
    //
    // Notes: Trigger events are only sent if one of the Colliders also has a Rigidbody attached.
    // Trigger events will be sent to disabled MonoBehaviours, to allow enabling Behaviours in
    // response to collisions. OnTriggerEnter occurs on the FixedUpdate after a collision. The
    // Colliders involved are not guaranteed to be at the point of initial contact.
    // https://docs.unity3d.com/ScriptReference/Collider.OnTriggerEnter.html
    //
    private void OnTriggerEnter2D(Collider2D collision)
    {
        Debug.Log("Activation zone: trigger detected with " + collision.name);
        // if object is a wave spawner object, start wave
        Activatable gameObject = collision.GetComponent <Activatable>();

        if (gameObject == null)
        {
            return;
        }
        gameObject.Activate();
    }
Пример #16
0
 IEnumerator CallActivatable()
 {
     if (waitOneFrame)
     {
         yield return(new WaitForEndOfFrame());
     }
     else
     {
         yield return(null);
     }
     activatable.Activate();
 }
Пример #17
0
 public void Activate()
 {
     if (!bonusActivator && objectToActivate)
     {
         objectToActivate.Activate();
     }
     activated = true;
     //Debug.Log(spriteRenderer.sprite.name);
     //Debug.Log(activatedSprite.name);
     spriteRenderer.sprite = activatedSprite;
     timeUntilDeactivation = timeUntilDeactivationMax;
 }
Пример #18
0
    public void PowerUpReceptor()
    {
        //_activating = true;
        activatable.Activate();

        if (activeMaterialsArray != null)
        {
            audioSource.PlayOneShot(activatedClip);
            mesh.materials = activeMaterialsArray;
        }

        _activationCount++;
    }
Пример #19
0
    void Update()
    {
        if (currentDestination >= destinations.Length)
        {
            return;
        }
        Transform dt = destinations[currentDestination];

        if (flipToMovement)
        {
            target.transform.localScale = new Vector3(
                Mathf.Sign(dt.position.x - target.transform.position.x),
                1,
                1
                );
        }
        target.transform.position = Vector2.MoveTowards(target.transform.position, dt.position, speed * Time.deltaTime);
        if (Vector2.Distance(target.transform.position, dt.transform.position) < Vector2.kEpsilon)
        {
            currentDestination += 1;
            if (currentDestination >= destinations.Length && loop)
            {
                if (closeLoop)
                {
                    currentDestination = 0;
                }
                else
                {
                    // just move back to the starting point
                    target.transform.position = destinations[0].position;
                    currentDestination        = 1;
                }
            }
            if (callback != null)
            {
                callback.Activate();
            }
        }

        if (sendSpeedToAnimator)
        {
            float currentSpeed = speed;
            if (Vector2.Distance(target.transform.position, dt.transform.position) < Vector2.kEpsilon)
            {
                currentSpeed = 0;
            }
            float angle = Vector2.Angle(dt.transform.position - target.transform.position, Vector2.right) * Mathf.Deg2Rad;
            animator.SetFloat("SpeedX", Mathf.Abs(currentSpeed * Mathf.Cos(angle)));
            animator.SetFloat("SpeedY", Mathf.Abs(currentSpeed * Mathf.Sin(angle)));
        }
    }
Пример #20
0
 override protected void Die()
 {
     bossHealthUI.gameObject.SetActive(false);
     if (deathActivatable != null)
     {
         deathActivatable.Activate();
     }
     if (victoryEffectOnDeath)
     {
         Instantiate(victoryEffect, transform.position, Quaternion.identity, null);
     }
     base.Die();
     stopBossFight.Raise();
 }
Пример #21
0
 override public void Activate()
 {
     foreach (GameState s in gameStates)
     {
         if (!GlobalController.HasState(s))
         {
             if (noActivatable != null)
             {
                 noActivatable.Activate();
             }
             return;
         }
         yesActivatable.Activate();
     }
 }
Пример #22
0
 void AcceptItems()
 {
     if (consumesItems)
     {
         foreach (Item wantedItem in wanted)
         {
             GlobalController.inventory.items.RemoveItem(new StoredItem(wantedItem));
         }
     }
     acceptedItemBefore = true;
     UpdateObjectState();
     if (yesActivation != null)
     {
         yesActivation.Activate();
     }
 }
Пример #23
0
 void OnTriggerEnter2D(Collider2D other)
 {
     if (!armed)
     {
         return;
     }
     foreach (string s in wantedTags)
     {
         if (other.gameObject.CompareTag(s))
         {
             activatable.Activate();
             StartCoroutine(CoolDown(cooldown));
             return;
         }
     }
 }
Пример #24
0
 private void Action(Activatable activatable)
 {
     if (InputHandler.GetButton(InputHandler.Input.Action) && activatable != null)
     {
         activationTimer += Time.deltaTime;
         if (activationTimer > activatable.ActivationTime)
         {
             activatable.Activate(this);
             activationTimer = 0.0f;
         }
     }
     else
     {
         activationTimer = 0.0f;
     }
 }
Пример #25
0
 void AcceptItems()
 {
     if (consumesItems)
     {
         List <InventoryItem> actualWantedItems = wantedItems.Select(x => x.GetItem()).ToList();
         foreach (InventoryItem wantedItem in actualWantedItems)
         {
             GlobalController.inventory.items.RemoveItem(wantedItem);
         }
     }
     acceptedItemBefore = true;
     UpdateObjectState();
     if (yesActivation != null)
     {
         yesActivation.Activate();
     }
 }
Пример #26
0
 override public void Activate()
 {
     foreach (GameFlag f in gameFlags)
     {
         if (!GlobalController.HasFlag(f))
         {
             if (noActivatable != null)
             {
                 noActivatable.Activate();
                 if (yesActivatable != null)
                 {
                     yesActivatable.ActivateSwitch(false);
                 }
                 return;
             }
         }
         yesActivatable.Activate();
     }
 }
Пример #27
0
    public void OnSubmit()
    {
        if (!DialogueUI.LineFullyRendered())
        {
            return;
        }

        // in the case of a generic "exit" button
        if (activatable != null)
        {
            activatable.Activate();
        }
        ChoiceUI.CloseChoices();
        // if clicked this frame, mimic a dialogue skip input
        if (!InputManager.GenericContinueInput())
        {
            GlobalController.OnDialogueSkip();
        }
    }
Пример #28
0
 override public void Activate()
 {
     if (!sceneFlag.gotten)
     {
         if (noActivatable != null)
         {
             noActivatable.Activate();
             if (yesActivatable != null)
             {
                 yesActivatable.ActivateSwitch(false);
             }
             return;
         }
     }
     yesActivatable.Activate();
     if (resetsFlag)
     {
         sceneFlag.gotten = false;
     }
 }
Пример #29
0
 void Update()
 {
     if (TimeManager.Paused)
     {
         return;
     }
     Reset();
     if (stun.OnCooldown())
     {
         return;
     }
     LocateCurrentActivatable();
     if (Input.GetButtonDown("Activate"))
     {
         if (current != null)
         {
             current.Activate(this);
         }
     }
 }
Пример #30
0
    private ActivationResult ApplyActivatable(Activatable activatable, Character instigator, ulong timestamp, bool extra)
    {
        ActivationResult activationResult;

        if (!activatable)
        {
            activationResult = ActivationResult.Error_Destroyed;
        }
        else
        {
            ContextActivator.ActivationMode activationMode = this.activationMode;
            if (activationMode == ContextActivator.ActivationMode.TurnOn)
            {
                activationResult = activatable.Activate(true, instigator, timestamp);
            }
            else
            {
                activationResult = (activationMode == ContextActivator.ActivationMode.TurnOff ? activatable.Activate(false, instigator, timestamp) : activatable.Activate(instigator, timestamp));
            }
        }
        return(activationResult);
    }