예제 #1
0
 // Use this for initialization
 void Start()
 {
     if (instance == null)
     {
         instance = this;
     }
 }
예제 #2
0
 private void Awake()
 {
     if (instance == null)
     {
         instance = this;
     }
 }
        private void Awake()
        {
            BloodManager       = GetComponent <BloodManager>();
            SoundManagerZombie = GetComponent <SoundManager>();
            //GlobalVariables = gameManager.GetComponent<GlobalGameVariables>();
            GlobalVariables = GameObject.Find("GameManager").GetComponent <GlobalGameVariables>();

            inventory = GetComponent <Inventory>();
            anim      = gameObject.GetComponent <Animator>();

            CurrentHealth = MaximumHealth;
            _playerHealth = GetComponent <PlayerHealth>();
        }
 public override void Die()
 {
     Debug.Log(name + " is dead.");
     GetComponent <ZombieArea>().Kill();
     // Find and disable the Nav Mesh Agent.
     GetComponent <NavMeshAgent>().enabled = false;
     // The enemy is dead.
     IsDead = true;
     // Tell the animator that the enemy is dead.
     anim.SetTrigger("Dead");
     GetComponent <CapsuleCollider>().isTrigger = true;
     BloodManager.PlayDeath();
     // After 2 seconds destory the enemy.
     Destroy(gameObject, GlobalVariables.DeadBodyLifetime);
 }
예제 #5
0
파일: cutter.cs 프로젝트: FraserLee/LD46
    void Update()
    {
        if (Input.GetMouseButtonDown(0))
        {
            phase = (phase + 1) % 3;
            switch (phase)
            {
            case 0:
                if (heldPart != null)
                {
                    if (clickable.clickedTag != "table")
                    {
                        heldPart.gameObject.GetComponent <SpriteRenderer>().color = new Color(1.0f, 1.0f, 1.0f, 0.15f);
                        BloodManager.KillSpurt();
                    }
                    heldPart.targetPos = heldPart.getPos();
                    heldPart           = null;
                }
                break;

            case 1:
                lr.enabled            = true;
                lr.SetPosition(0, src = getMouseWorldPos());
                break;

            case 2:
                lr.enabled = false;
                //<slice>
                //var k = getMouseWorldPos();
                //var rp = (src+k)*.5f-currentBody.transform.position;
                //float rot = Mathf.Atan2(src.y-k.y, src.x-k.x)*Mathf.Rad2Deg;
                //if(Mathf.DeltaAngle(Mathf.Atan2(rp.y, rp.x)*Mathf.Rad2Deg,rot)>0)rot+=180;
                //k=(src+k)*.5f;
                //k.z=rot+90;
                //heldPart=currentBody.Slice(k);

                //</slice>
                //k.z=0;
                RaycastHit2D[] hit = Physics2D.RaycastAll(lr.GetPosition(0), lr.GetPosition(1));


                if (hit.Length > 0)
                {
                    BodyPartSurgery hitBodyPart = hit[0].collider.gameObject.GetComponent <BodyPartSurgery>();

                    if (hitBodyPart != null)
                    {
                        Debug.Log("Heureka bitch");
                        Vector3 cutOffset = hit[0].point - new Vector2(hitBodyPart.gameObject.transform.position.x, hitBodyPart.gameObject.transform.position.y);
                        BloodManager.Spurt(hitBodyPart, cutOffset);
                    }
                }


                break;
            }
        }
        if (lr.enabled)
        {
            lr.SetPosition(1, getMouseWorldPos());
        }
        if (heldPart != null)
        {
            heldPart.targetPos = getMouseWorldPos();
        }
    }
예제 #6
0
 private void Awake()
 {
     instance = this;
     _bloodExplosionPrefab = Resources.Load <GameObject>("Effects/BloodExplosion");
 }
예제 #7
0
    // Update is called once per frame
    void Update()
    {
        RaycastHit2D hit;

        //int layerMask = 1 << LayerMask.NameToLayer("Booty");
        //layerMask = ~layerMask;
        BodyPartSurgery hitBodyPart = null;

        hit = Physics2D.Raycast(Camera.main.ScreenToWorldPoint(Input.mousePosition), Vector2.zero, Mathf.Infinity);
        if (hit.collider != null)
        {
            hitBodyPart = hit.collider.gameObject.GetComponent <BodyPartSurgery>();
            if (hitBodyPart != null)
            {
                if (LastHitBodyPart != null && LastHitBodyPart != hitBodyPart)
                {
                    LastHitBodyPart.DeHighlight();
                }
                LastHitBodyPart = hitBodyPart;
                if (LastHitBodyPart != null && LastHitBodyPart.bCanBeDetached)
                {
                    LastHitBodyPart.Highlight(ColorHighlightCut);
                }
            }
            else
            {
                if (LastHitBodyPart != null)
                {
                    LastHitBodyPart.DeHighlight();
                    LastHitBodyPart = null;
                }
            }
        }
        else
        {
            if (LastHitBodyPart != null)
            {
                LastHitBodyPart.DeHighlight();
                LastHitBodyPart = null;
            }
        }

        if (Input.GetMouseButtonDown(0))
        {
            if (hitBodyPart != null)
            {
                //TODO: start drag body part
                if (hitBodyPart.bIsDetached)
                {
                    DraggedBodyPart = hitBodyPart;
                    DragOffset      = (new Vector3(hit.point.x, hit.point.y) - DraggedBodyPart.gameObject.transform.position);
                }
                else
                {
                    MouseDragStart = getMouseWorldPos();
                    LineCut.SetPosition(0, MouseDragStart);
                }
            }
            else
            {
                MouseDragStart = getMouseWorldPos();
                LineCut.SetPosition(0, MouseDragStart);
            }
        }

        if (Input.GetMouseButton(0))
        {
            if (DraggedBodyPart != null)
            {
                //TODO: update position of dragged body part
                DraggedBodyPart.gameObject.transform.position = getMouseWorldPos() - DragOffset;

                if (BodySurgery.Henry.CanAttach(DraggedBodyPart) &&
                    Vector3.Distance(DraggedBodyPart.SpurtMarker.transform.position,
                                     BodySurgery.Henry.GetSnapPositionForBodyPart(DraggedBodyPart.Type)) < 1.2f)
                {
                    DraggedBodyPart.bPendingAttach = true;
                    DraggedBodyPart.HighlightLock(ColorHighlightAttach);
                    DraggedBodyPart.transform.position = Vector3.zero;
                }
                else
                {
                    DraggedBodyPart.bPendingAttach = false;
                    DraggedBodyPart.DeHighlight();
                }
            }
            else
            {
                LineCut.SetPosition(1, getMouseWorldPos());
                if (Vector3.Distance(LineCut.GetPosition(0), LineCut.GetPosition(1)) > 0.5f)
                {
                    LineCut.enabled = true;
                }
                else
                {
                    LineCut.enabled = false;
                }
            }
        }

        if (Input.GetMouseButtonUp(0))
        {
            if (DraggedBodyPart != null)
            {
                //TODO: drop body part
                if (DraggedBodyPart.bPendingAttach)
                {
                    DraggedBodyPart.Attach();

                    AudioManager.Instance.PlaySoundOneShot(AudioManager.Instance.ClipsSurgeryReplace[Random.Range(0, AudioManager.Instance.ClipsSurgeryReplace.Count)]);
                }
                else
                {
                    if (!SurgeryManager.Instance.PendingPartsToTransfer.Contains(DraggedBodyPart.Type) || !DraggedBodyPart.bIsMatch)
                    {
                        BloodManager.Spurt(DraggedBodyPart, Vector3.zero);
                        Destroy(DraggedBodyPart.gameObject);
                    }
                    AudioManager.Instance.PlaySoundOneShot(AudioManager.Instance.ClipsSurgeryDrop[Random.Range(0, AudioManager.Instance.ClipsSurgeryDrop.Count)]);
                }
            }
            else
            {
                MouseDragEnd = getMouseWorldPos();
                LineCut.SetPosition(1, MouseDragEnd);
                LineCut.enabled = false;

                if (Vector3.Distance(LineCut.GetPosition(0), LineCut.GetPosition(1)) > 0.5f)
                {
                    RaycastHit2D[] cutHits = Physics2D.RaycastAll(MouseDragStart,
                                                                  (MouseDragEnd - MouseDragStart).normalized,
                                                                  Vector3.Distance(MouseDragStart, MouseDragEnd));


                    if (cutHits.Length > 0)
                    {
                        for (int i = 0; i < cutHits.Length; ++i)
                        {
                            BodyPartSurgery hitBodyPartCut = cutHits[i].collider.gameObject.GetComponent <BodyPartSurgery>();
                            if (hitBodyPartCut != null && !hitBodyPartCut.bIsDetached)
                            {
                                Debug.Log("Heureka bitch");
                                Vector3 cutOffset = cutHits[i].point - new Vector2(hitBodyPartCut.gameObject.transform.position.x, hitBodyPartCut.gameObject.transform.position.y);
                                BloodManager.Spurt(hitBodyPartCut, cutOffset);
                                hitBodyPartCut.Detach();
                                break;
                            }
                        }
                    }
                }
                else
                {
                }
            }
            DraggedBodyPart = null;
        }
    }