Animate() public method

Animate between the specified StartFrame and EndFrame.
public Animate ( int StartFrame, int EndFrame ) : IEnumerator
StartFrame int Start frame.
EndFrame int End frame.
return IEnumerator
コード例 #1
0
    public string caster;     //who has cast the project. It will ignore them.

    void OnCollisionEnter(Collision collision)
    {
        if (collision.gameObject.name == caster)
        {
            return;
        }
        if (HasHit == true)
        {        //Only impact once.
            return;
        }
        else

        {
            HasHit = true;
            SpriteRenderer sprt = this.GetComponentInChildren <SpriteRenderer>();
            sprt.enabled = false;
            BoxCollider box = this.GetComponent <BoxCollider>();
            box.enabled = false;
            WindowDetect.FreezeMovement(this.gameObject);

            ObjectInteraction objInt = collision.gameObject.GetComponent <ObjectInteraction>();

            if (objInt != null)
            {
                objInt.Attack(damage);
                Impact imp = this.gameObject.AddComponent <Impact>();
                imp.FrameNo  = objInt.GetHitFrameStart();
                imp.EndFrame = objInt.GetHitFrameEnd();
                StartCoroutine(imp.Animate());
            }
            else
            {
                //test if this is a player.
                if (collision.gameObject.GetComponent <UWCharacter>() != null)
                {
                    collision.gameObject.GetComponent <UWCharacter>().ApplyDamage(damage);
                }
                else
                {
                    //do a miss impact
                    Impact imp = this.gameObject.AddComponent <Impact>();
                    imp.FrameNo  = 46;
                    imp.EndFrame = 50;
                    StartCoroutine(imp.Animate());
                }
            }

            DestroyObject(this.gameObject, 1);
        }
    }
コード例 #2
0
    public override IEnumerator ExecuteMelee()
    {
        Charge         = 0.0f;
        AttackCharging = false;

        yield return(new WaitForSeconds(0.6f));

        Ray ray;

        if (playerUW.MouseLookEnabled == true)
        {
            ray = Camera.main.ViewportPointToRay(new Vector3(0.5f, 0.5f, 0f));
        }
        else
        {
            ray = Camera.main.ScreenPointToRay(Input.mousePosition);
        }

        RaycastHit hit = new RaycastHit();

        if (Physics.Raycast(ray, out hit, weaponRange))
        {
            if (hit.transform.Equals(this.transform))
            {
                //Debug.Log ("you've hit yourself ? " + hit.transform.name);
            }
            else
            {
                ObjectInteraction objInt = hit.transform.gameObject.GetComponent <ObjectInteraction>();
                if (objInt != null)
                {
                    hit.transform.gameObject.GetComponent <ObjectInteraction>().Attack(10);
                    //Create a blood splatter at this point
                    GameObject hitimpact = new GameObject(hit.transform.name + "_impact");
                    hitimpact.transform.position = hit.point;                  //ray.GetPoint(weaponRange/0.7f);
                    Impact imp = hitimpact.AddComponent <Impact>();
                    imp.FrameNo  = objInt.GetHitFrameStart();
                    imp.EndFrame = objInt.GetHitFrameEnd();
                    StartCoroutine(imp.Animate());
                    if (currWeapon != null)
                    {
                        currWeapon.onHit(hit.transform.gameObject);
                    }
                }
                else
                {
                    //do a miss impact
                    GameObject hitimpact = new GameObject(hit.transform.name + "_impact");
                    hitimpact.transform.position = hit.point;                  //ray.GetPoint(weaponRange/0.7f);
                    Impact imp = hitimpact.AddComponent <Impact>();
                    imp.FrameNo  = 46;
                    imp.EndFrame = 50;
                    StartCoroutine(imp.Animate());
                    if (currWeapon != null)
                    {
                        currWeapon.onHit(null);
                    }
                }
            }
        }
        else
        {
            if (currWeapon != null)
            {
                currWeapon.onHit(null);
            }
        }

        AttackExecuting = false;
    }