示例#1
0
    public override void StartObject(Vector2 direction, float launchSpeed)
    {
        //Since there is a delay before we get the master, we need to check if we have get the masters or not
        float yDestination = yScreen.y;

        if (yDestination == 0)
        {
            yDestination = GlobalState.GetCameraYBound(mainCamera).y *GlobalState.yScreenClamp;
        }
        else
        {
            yDestination *= GlobalState.yScreenClamp;
        }

        //Move from top of the screen
        transform.parent.transform.DOMoveY(yDestination * 0.9f, 3).SetEase(Ease.Flash);
        StartCoroutine(InvisibleForSomeTime(3));                        //Be invicible for some time
        Invoke("StartAttack", 3);                                       //Then attack
    }
    // Use this for initialization
    void Awake()
    {
        //Find the border
        myBorder = GameObject.Find("Border").transform;

        //Get the masters
        collectorMaster    = GameObject.Find("Collector").transform;
        objectsMaster      = collectorMaster.Find("Objects Master").transform;
        alliesMaster       = collectorMaster.Find("Allies Master").transform;
        collectiblesMaster = collectorMaster.Find("Collectibles Master").transform;

        objectsMasterScript      = objectsMaster.GetComponent <Collector>();
        alliesMasterScript       = alliesMaster.GetComponent <Collector>();
        collectiblesMasterScript = collectiblesMaster.GetComponent <Collector>();

        notificationText = GameObject.Find("Notification Text").GetComponent <NotificationText>();
        introOutroAnim   = GameObject.Find("Intro Outro").GetComponent <Animator>();

        mainCamera = GameObject.Find("Main Camera").GetComponent <Camera>();
        xScreen    = GlobalState.GetCameraXBound(mainCamera);
        yScreen    = GlobalState.GetCameraYBound(mainCamera);

        if (myBorder != null)
        {
            borderCollider = myBorder.GetComponent <BoxCollider2D>();
            if (borderCollider != null)
            {
                //Adjust the collider size as 1.5 size of the screen size (* 2 because size = 2 * xScreen)
                borderCollider.size = new Vector2(xScreen.y * 1.7f * 2, yScreen.y * 1.3f * 2);
                xBoundary.x         = myBorder.transform.position.x - borderCollider.size.x / 2 + 1;
                xBoundary.y         = myBorder.transform.position.x + borderCollider.size.x / 2 - 1;

                yBoundary.x = myBorder.transform.position.y - borderCollider.size.y / 2 + 1;
                yBoundary.y = myBorder.transform.position.y + borderCollider.size.y / 2 - 1;
            }
        }
    }