Inheritance: MonoBehaviour
コード例 #1
0
    protected virtual void OnCollisionEnter2D(Collision2D coll)
    {
        if (!shielded)
        {
            if (coll.gameObject.tag == "DebuffArea")
            {
                debuff = true;
            }
        }

        if (coll.gameObject.tag == "Wall")
        {
            this.GetComponent <Rigidbody2D>().simulated = false;
            this.GetComponent <Collider2D>().enabled    = false;
            WallBehaviour wall = coll.gameObject.GetComponent <WallBehaviour>();
            if (!wall.oob)
            {
                StartCoroutine(WaitToDestroy(wall));
            }
            else
            {
                Death();
            }
        }
    }
コード例 #2
0
    private void Shoot()
    {
        if (gunAnimation.isPlaying)
        {
            return;
        }

        if (gunAnimation != null)
        {
            gunAnimation.Play();
        }

        if (shootSound != null)
        {
            AudioSource.PlayClipAtPoint(shootSound, transform.position, 1.0f);
        }

        int remainingDamage = damage;

        while (remainingDamage > 0 && objectsInTrajectory.Count > 0)
        {
            WallBehaviour current   = objectsInTrajectory.First.Value;
            int           hitPoints = current.CurrentHitPoints;

            if (hitPoints <= remainingDamage)
            {
                objectsInTrajectory.RemoveFirst();
            }

            current.CurrentHitPoints -= remainingDamage;
            remainingDamage          -= hitPoints;
        }
    }
コード例 #3
0
    protected virtual IEnumerator WaitToDestroy(WallBehaviour wall)
    {
        yield return(new WaitForSeconds(0.1f));

        wall.health -= damageDealth;
        Death();
    }
コード例 #4
0
ファイル: FirePortal.cs プロジェクト: EAX94/Rocket
    private bool DrawPortal(Color portalColor, RaycastHit2D rayCastHit, Vector2 mousePosition, Vector2 userPosition)
    {
        WallBehaviour wallHit = (WallBehaviour)rayCastHit.collider.GetComponent("WallBehaviour");

        this.DrawLineEffect(portalColor, rayCastHit, userPosition);

        if (!wallHit)
        {
            return(false);
        }

        if (!wallHit.portalAvailable)
        {
            return(false);
        }

        bool portalOk = this.CheckSpaceInWall(wallHit.verticalWallLeft || wallHit.verticalWallRight, userPosition, ref rayCastHit, wallHit.wallGuid);

        if (!portalOk)
        {
            return(false);
        }

        ++this.portalCount;

        GameObject actualPortal;

        actualPortal = (this.portalCount % 2 == 0) ? portal1 : portal2;

        int portalOrientation;

        if (wallHit.verticalWallLeft || wallHit.verticalWallRight)
        {
            rayCastHit.point = new Vector2(rayCastHit.point.x - 0.75f, rayCastHit.point.y);

            if (wallHit.verticalWallRight)
            {
                rayCastHit.point = new Vector2(rayCastHit.point.x + 1.5f, rayCastHit.point.y);
            }

            portalOrientation = 0;
        }
        else
        {
            rayCastHit.point = new Vector2(rayCastHit.point.x, rayCastHit.point.y + 0.75f);

            if (wallHit.horizontalWallDown)
            {
                rayCastHit.point = new Vector2(rayCastHit.point.x, rayCastHit.point.y - 1.5f);
            }

            portalOrientation = 1;
        }

        PortalBehaviour portalScript = (PortalBehaviour)actualPortal.GetComponent("PortalBehaviour");

        portalScript.PortalOn(rayCastHit.point, portalOrientation, wallHit);

        return(true);
    }
コード例 #5
0
 private void SpawnObstacles(Room room, float horizontalShift, float verticalShift)
 {
     foreach (Vector3 loc in room.obstacles)
     {
         WallBehaviour wall = Instantiate(wallPrefab);
         wall.SetPosition(new Vector3(horizontalShift + 5f * loc.x, verticalShift + 2.5f * loc.y, 0));
         //GameObject e = Instantiate(GlobalObjects.wallPrefab, new Vector3(100, 100, 0), GlobalObjects.wallPrefab.transform.rotation);
         //e.GetComponent<WallBehaviour>().SetPosition(new Vector3(horizontalShift + 5f * loc.x, verticalShift + 2.5f * loc.y, 0));
     }
 }
コード例 #6
0
    private void AddWallUnit(float x, float y, string axis)
    {
        WallBehaviour wall = Instantiate(wallPrefab);

        if (axis.Equals("x"))
        {
            wall.SetPosition(new Vector3(x, y, 0));
        }
        else
        {
            wall.SetPosition(new Vector3(y, x, 0));
        }
    }
コード例 #7
0
ファイル: PortalBehaviour.cs プロジェクト: EAX94/Rocket
    public void PortalOn(Vector2 portalPosition, int portalOrientation, WallBehaviour wallHit)
    {
        this.portalEnabled = true;
        //this.spriteRender = this.GetComponent<SpriteRenderer>();
        this.spriteRender.color = new Color(this.spriteRender.color.r, this.spriteRender.color.g, this.spriteRender.color.b, 1.0f);

        this.transform.position    = portalPosition;
        this.transform.eulerAngles = new Vector3(this.transform.eulerAngles.x, this.transform.eulerAngles.y, 90.0f * portalOrientation);

        this.verticalPortalLeft   = wallHit.verticalWallLeft;
        this.verticalPortalRight  = wallHit.verticalWallRight;
        this.horizontalPortalUp   = wallHit.horizontalWallUp;
        this.horizontalPortalDown = wallHit.horizontalWallDown;

        this.portalActualFrame = 0;
    }