상속: MonoBehaviour
    private void Start()
    {
        ToggleVisible();
        numSelections = selectionTiles.Length;

        tilesHotbar  = GetComponent <Tilemap>();
        hotbarCenter = new Vector3Int(0, 0, 0);
        ChangeSelection(0);

        cam = Camera.main;
        horizontalPosition = horizontalPositionPercentage * Screen.width * 0.01f;
        verticalPosition   = verticalPositionPercentage * Screen.height * 0.01f;
        float   zPosition = transform.position.z;
        Vector3 position  = cam.ScreenToWorldPoint(new Vector3(horizontalPosition, verticalPosition, 0));

        transform.position = new Vector3(position.x, position.y, zPosition);
        hotbarSelection.transform.position = transform.position + new Vector3(0, 0, -1);

        //Item1 is on entering mousedown state, Item2 is repeated every frame while the mouse is down
        selectionActions = new Tuple <Action, Action, Action, Action>[]
        {
            new Tuple <Action, Action, Action, Action> (() => ToggleIfAbleElseDo(DoNothing), () => ReplaceTile("dirt"), DoNothing, RemoveUnderCursor),
            new Tuple <Action, Action, Action, Action> (() => ToggleIfAbleElseDo(DoNothing), () => ReplaceTile("coal"), DoNothing, RemoveUnderCursor),
            new Tuple <Action, Action, Action, Action> (() => ToggleIfAbleElseDo(() => PlaceEntity("wheel")), DoNothing, DoNothing, RemoveUnderCursor),
            new Tuple <Action, Action, Action, Action> (() => ToggleIfAbleElseDo(() => PlaceEntity("miner")), DoNothing, DoNothing, RemoveUnderCursor),
            new Tuple <Action, Action, Action, Action> (() => ToggleIfAbleElseDo(DoNothing), () => PlaceEntity("sheep"), DoNothing, RemoveUnderCursor),
            new Tuple <Action, Action, Action, Action> (() => ToggleIfAbleElseDo(DoNothing), () => ReplaceTile("rock"), DoNothing, RemoveUnderCursor)
        };

        cursorScript = cursorSelection.GetComponent <CursorScript>();
    }
    // Start is called before the first frame update
    void Start()
    {
        Time.timeScale = 1;
        winLevel.SetActive(false);
        loseLevel.SetActive(false);
        cursor          = this.gameObject.GetComponent <CursorScript>();
        activeResource  = null;
        numResources    = resources.Length;
        resourceAmounts = new float[numResources];

        for (int i = 0; i < numResources; i++)
        {
            resourceAmounts[i] = initResourceAmts[i];
            if (resources[i].tag == "House")
            {
                populationSlider.setMaxValue(2 * initResourceAmts[i] + 10);
                populationText.setNumber(initResourceAmts[i]);
            }
            else if (resources[i].tag == "Farm")
            {
                foodSlider.setMaxValue(2 * initResourceAmts[i] + 10);
                foodText.setNumber(initResourceAmts[i]);
            }
            else if (resources[i].tag == "River")
            {
                waterSlider.setMaxValue(2 * initResourceAmts[i] + 10);
                waterText.setNumber(initResourceAmts[i]);
            }
        }
    }
예제 #3
0
 void Start()
 {
     //QuestManagerScript = QuestManager.GetComponent<QuestManager>();
     GameManager     = GameObject.FindGameObjectWithTag("Scene");
     cursorScript    = GameManager.GetComponent <CursorScript>();
     dialoguePanel   = GameObject.FindGameObjectWithTag("Dialogue").GetComponent <CanvasGroup>();
     dialogueContent = GameObject.FindGameObjectWithTag("DialogueContent");
 }
예제 #4
0
    public void LoadCursor()
    {
        GameObject cursorObject = GameObject.FindGameObjectWithTag("Cursor");

        if (cursorObject != null)
        {
            cursor = cursorObject.GetComponent <CursorScript>();
        }
    }
예제 #5
0
 public void ProxyObjectExit(GameObject oldProxy)
 {
     if (proxyObject == oldProxy)
     {
         proxyObject = null;
         proxyType   = ProxyObjectType.NONE;
         CursorScript.RemoveCursors();
     }
 }
예제 #6
0
 // Use this for initialization
 void Start()
 {
     handCursor = GameObject.Find("HandCursor").GetComponent<CursorScript>();
     inputX = 0;
     inputY = 0;
     if(!mouseMode){
         kinectManager = Object.Instantiate(kinectManagerPrefab, Vector3.zero, Quaternion.identity) as KinectManager;
         kinectManager.HandCursor1 = handCursor;
     }
 }
예제 #7
0
    private void Start()
    {
        GetComponent <SpriteRenderer>().enabled = false;
        cursorSelection.GetComponent <SpriteRenderer>().enabled = false;

        myRigidbody2D = GetComponent <Rigidbody2D>();
        //myTransform = GetComponent<Transform>();
        cursorScript = cursorSelection.GetComponent <CursorScript>();
        InitializeCamera();
    }
예제 #8
0
    public void ResetLevel()
    {
        //reset the level
        Destroy(GameObject.FindGameObjectWithTag("Player"));
        player = (GameObject)GameObject.Instantiate(playerPrefab, playerStartPosition, Quaternion.identity);
        CursorScript.RemoveCursors();

        //increment the deaths
        deaths++;
    }
예제 #9
0
 //play the death animation and reset the level
 public void Die()
 {
     animator.SetBool("isDying", true);
     isRooted = false;
     CursorScript.RemoveCursors();
     if (rigidbody2D.gravityScale != gravityScale)
     {
         rigidbody2D.gravityScale = gravityScale;
     }
 }
예제 #10
0
 // Use this for initialization
 void Start()
 {
     handCursor = GameObject.Find("HandCursor").GetComponent <CursorScript>();
     inputX     = 0;
     inputY     = 0;
     if (!mouseMode)
     {
         kinectManager             = Object.Instantiate(kinectManagerPrefab, Vector3.zero, Quaternion.identity) as KinectManager;
         kinectManager.HandCursor1 = handCursor;
     }
 }
예제 #11
0
 private void Start()
 {
     eHealth            = eStartHealth;
     _gameManager       = GameObject.Find("GameManager").GetComponent <GameManager>();
     HealthAmmount.text = eHealth.ToString() + " / " + eStartHealth.ToString();
     target             = GameObject.FindGameObjectWithTag("Player").GetComponent <Transform>();
     _player            = GameObject.FindGameObjectWithTag("Player").GetComponent <Player>();
     _audioSource       = GetComponent <AudioSource>();
     _randHurtSound     = Random.Range(0, 3);
     _cursor            = GameObject.FindGameObjectWithTag("Cursor").GetComponent <CursorScript>();
 }
예제 #12
0
 void Awake()
 {
     if (instance == null)
     {
         instance = this;
         DontDestroyOnLoad(gameObject);
     }
     else
     {
         Destroy(gameObject);
     }
 }
예제 #13
0
    public void ClientCardPeel(int grabbed_id, int player_id)
    {
        // Return if player is already holding something
        foreach (GameObject grabbable in grabbable_objects)
        {
            if (grabbable.GetComponent <GrabbableScript>().held_by_player_ == player_id)
            {
                return;
            }
        }
        // Find the deck, return if can't find it
        GameObject deck = null;

        foreach (GameObject grabbable in grabbable_objects)
        {
            if (grabbable.GetComponent <GrabbableScript>().id_ == grabbed_id &&
                grabbable.GetComponent <DeckScript>())
            {
                deck = grabbable;
            }
        }
        if (!deck)
        {
            return;
        }
        // Grab whatever card is on top of the deck, depending on which way
        // the deck is facing
        GameObject card = null;

        if ((deck.rigidbody.rotation * new Vector3(0, 1, 0)).y >= 0.0f)
        {
            card = deck.GetComponent <DeckScript>().TakeCard(true);
        }
        else
        {
            card = deck.GetComponent <DeckScript>().TakeCard(false);
        }
        card.GetComponent <GrabbableScript>().held_by_player_ = player_id;
        CursorScript cursor_script = null;

        foreach (GameObject cursor in cursor_objects)
        {
            if (cursor.GetComponent <CursorScript>().id() == player_id)
            {
                cursor_script = cursor.GetComponent <CursorScript>();
            }
        }
        cursor_script.SetCardFaceUp((card.transform.up.y < 0.0f));
        cursor_script.SetCardRotated(GetRotateFromGrabbable(card));
        card.GetComponent <CardScript>().PickUpSound();
    }
예제 #14
0
    // Use this for initialization
    void Start()
    {
        ourGlobalScript = this;

        ourUnitScripts = Object.FindObjectsOfType<UnitScript>();

        ourPlayerScripts = Object.FindObjectsOfType<PlayerScript>();

        ourCursorScript = Object.FindObjectOfType<CursorScript>();

        ourTurnScript = Object.FindObjectOfType<TurnScript>();

        ourPhaseScript = Object.FindObjectOfType<PhaseScript>();
    }
예제 #15
0
    // Use this for initialization
    void Start()
    {
        ourGlobalScript = this;

        ourUnitScripts = Object.FindObjectsOfType <UnitScript>();

        ourPlayerScripts = Object.FindObjectsOfType <PlayerScript>();

        ourCursorScript = Object.FindObjectOfType <CursorScript>();

        ourTurnScript = Object.FindObjectOfType <TurnScript>();

        ourPhaseScript = Object.FindObjectOfType <PhaseScript>();
    }
예제 #16
0
    private void Awake()
    {
        if (instance != null && instance != this)
        {
            Destroy(this.gameObject);
            return;
        }
        else
        {
            instance = this;
        }

        DontDestroyOnLoad(this.gameObject);
    }
예제 #17
0
    // Use this for initialization
    void Start()
    {
        manager = board.GetComponent <GameManager> ();
        CScript = CursorManager.GetComponent <CursorScript> ();
        ai      = CursorManager.GetComponent <AI> ();
        BGM     = GameObject.FindGameObjectWithTag("BGM");


        distance = 100;
        PlayerController.mycolor = 3;
        canmove  = true;
        timer    = 0;
        hitsound = Resources.Load("HitSound") as GameObject;
        bom      = Resources.Load("Detonator-Simple") as GameObject;
        mode     = 1;
    }
예제 #18
0
    // GridElementScript[][] mapClone; // so we don't have to foreach and search through all the GameObjects every time, as that is costly. use if noticeable lag occurs.
    // Use this for initialization
    void Start()
    {
        foreach (var e in GameObject.FindObjectsOfType<GridElementScript>())
        {
            if (!isLegalBoardLocation(e.x, e.y))
            {
                Debug.Log("ERROR: Illegal board position (" + e.x + "," + e.y + ") of unit " + e.gameObject.name);
                e.x = 0;
                e.y = 0;
            }
            e.gameObject.transform.position = Camera.main.GridToWorldPoint(new Vector3(e.x, e.y, e.gameObject.transform.position.z), this);
        }

        cursor = GameObject.FindObjectOfType<CursorScript>();
        if(cursor == null) Debug.Log("ERROR: Either no CursorScript object defined in scene, or more than one CursorScript object defined in scene.");
    }
    public void OnTriggerExit2D(Collider2D collision)
    {
        CursorScript cursor = collision.GetComponent <CursorScript>();

        cursorsHovering.Remove(cursor);

        // If the cursor has left this selector and not entered another at the same time, set it to null
        if (cursor.currentlyHoveredSelector == this)
        {
            cursor.currentlyHoveredSelector = null;
        }

        // only unhover if there are no cursors sitting on this boi
        if (cursorsHovering.Count == 0)
        {
            Unhover();
        }
    }
예제 #20
0
    public void SelectNewProxyObject(GameObject newProxy)
    {
        //if the current proxy object is null, the new proxy object becomes the current proxy object
        if (!proxyObject)
        {
            proxyObject = newProxy;
            CursorScript.CreateNewCursor(proxyObject.transform.position, cursorPrefab);
        }
        else
        {
            float currentDistance = (proxyObject.transform.position - transform.position).magnitude;
            float newDistance     = (newProxy.transform.position - transform.position).magnitude;

            if (currentDistance < newDistance)
            {
                proxyObject = newProxy;
                CursorScript.CreateNewCursor(proxyObject.transform.position, cursorPrefab);
            }
        }

        //select the correct type of proxy object
        switch (proxyObject.tag.ToUpper())
        {
        case "DOOR":
            proxyType = ProxyObjectType.DOOR;
            break;

        case "LEVER":
            proxyType = ProxyObjectType.LEVER;
            break;

        case "TELEPORTER":
            proxyType = ProxyObjectType.TELEPORTER;
            break;

        case "GRABPOINT":
            proxyType = ProxyObjectType.GRABPOINT;
            break;

        default:
            proxyType = ProxyObjectType.NONE;
            break;
        }
    }
    public void OnTriggerEnter2D(Collider2D collision)
    {
        Hover();
        CursorScript cursor = collision.GetComponent <CursorScript>();

        cursorsHovering.Add(cursor);

        // if the cursor is still touching another selector, unhover from that one
        if (cursor.currentlyHoveredSelector != null)
        {
            cursor.currentlyHoveredSelector.cursorsHovering.Remove(cursor);
            if (cursor.currentlyHoveredSelector.cursorsHovering.Count == 0)
            {
                cursor.currentlyHoveredSelector.Unhover();
            }
        }

        collision.GetComponent <CursorScript>().currentlyHoveredSelector = this;
    }
 // Use this for initialization
 void Start()
 {
     uiScript = (CursorScript) GameObject.Find ("Menu Cursor").GetComponent<CursorScript>();
     isHealing = false;
     enemy = new List<EnemyScript>();
     if (Application.loadedLevelName == "GrasslandsBattle")
     {
         EnemyScript enemySc1 = (EnemyScript) GameObject.Find("Green Spider").GetComponent<EnemyScript>();
         EnemyScript enemySc2 = (EnemyScript) GameObject.Find("Dark Troll").GetComponent<EnemyScript>();
         enemy.Add(enemySc1);
         enemy.Add (enemySc2);
     }
     else if (Application.loadedLevelName == "snowScene")
     {
         EnemyScript enemySc1 = (EnemyScript) GameObject.Find("skeletonMage").GetComponent<EnemyScript>();
         EnemyScript enemySc2 = (EnemyScript) GameObject.Find("skeletonSpearman").GetComponent<EnemyScript>();
         enemy.Add(enemySc1);
         enemy.Add (enemySc2);
     }
 }
예제 #23
0
    void Start()
    {
        playerCanvas = (Canvas)gameObject.GetComponentInChildren(typeof(Canvas), true);

        networkIdentity = gameObject.GetComponent <Mirror.NetworkIdentity>();
        if (!networkIdentity)
        {
            networkIdentity = gameObject.AddComponent <Mirror.NetworkIdentity>();
        }

        playerCursor = GetComponentInChildren <CursorScript>();

        FillDeck();
        FillHand();

        if (!isLocalPlayer)
        {
            // Disable all non-local player canvas UI elements
            playerCanvas.gameObject.SetActive(false);
            playerCursor.gameObject.SetActive(false);
        }
    }
예제 #24
0
    // Update is called once per frame
    void Update()
    {
        //if the level selection popup is not shown
        if (!showLevelWindow)
        {
            //check if the mouse has been moved
            bool mouseMoved = (previousMousePosition != Input.mousePosition);

            //if the mouse has been moved
            if (mouseMoved)
            {
                bool selectedChanged = false;

                //get the colliders at the mouse
                Collider2D[] points = Physics2D.OverlapPointAll(Camera.main.ScreenToWorldPoint(Input.mousePosition));

                //iterate through the colliders
                Collider2D country = null;
                foreach (Collider2D point in points)
                {
                    //if the collider is a country
                    if (point.tag == "Country")
                    {
                        //if this country is different from the selected one, select that country
                        country = point;
                        if (point.GetComponent <MenuCountryScript>().countryName != selectedCountry)
                        {
                            selectedCountry = point.GetComponent <MenuCountryScript>().countryName;
                            selectedChanged = true;
                        }

                        //break out of the loop
                        break;
                    }
                }

                //if a country is selected
                if (country)
                {
                    MenuCountryScript countryScript = country.gameObject.GetComponent <MenuCountryScript>();

                    //if the selection has changed, create a new cursor
                    if (selectedChanged)
                    {
                        CursorScript.CreateNewCursor(countryScript.cursorPoint, cursorPrefab);
                        selectedChanged = false;
                    }
                }
                else
                {
                    //if no country is selected, remove the cursor and set the selected country to none
                    CursorScript.RemoveCursors();
                    selectedCountry = MenuCountryScript.CountryName.NONE;
                }
            }

            //if the mouse has been clicked
            if (Input.GetMouseButtonDown(0) && selectedCountry != MenuCountryScript.CountryName.NONE)
            {
                //open the level selection pop up
                switch (selectedCountry)
                {
                case MenuCountryScript.CountryName.USA:
                    showLevelWindow = true;
                    break;

                case MenuCountryScript.CountryName.RUSSIA:
                    showLevelWindow = true;
                    break;

                default:
                    break;
                }
            }
        }
        else
        {
            if (Input.GetMouseButtonDown(0))
            {
                if (Input.mousePosition.x > windowRect.x + windowRect.size.x ||
                    Input.mousePosition.x < windowRect.x ||
                    Input.mousePosition.y > windowRect.y + windowRect.size.y ||
                    Input.mousePosition.y < windowRect.y)
                {
                    showLevelWindow = false;
                }
            }
        }

        //set the previous mouse position
        previousMousePosition = Input.mousePosition;
    }
예제 #25
0
 // Start is called before the first frame update
 void Start()
 {
     cursor = FindObjectOfType <CursorScript>();
     player = GameObject.FindGameObjectWithTag("Player");
 }
    // Use this for initialization
    void Start()
    {
        hpScript = gameObject.GetComponent<HealthScript>();
        damagedThisTurn = false;
        startOfHeal = true;
        state = "Standby";
        speed = 15.0f;

        attackDelay = 700.0f;
        attackTimer = attackDelay;
        nextTurnChoice = "";
        dmgBox = (DamageBoxScript) GameObject.Find ("DamageBox").GetComponent<DamageBoxScript>();
        uiScript = (CursorScript) GameObject.Find ("Menu Cursor").GetComponent<CursorScript>();
        aiScript = (EnemyAIScript) GameObject.Find ("Menu Cursor").GetComponent<EnemyAIScript>();
        maxHealth = GameObject.Find ("Menu Cursor").GetComponent<StatsScript>().GetMaxHP (gameObject.name);
        health = maxHealth;
        maxMana = GameObject.Find ("Menu Cursor").GetComponent<StatsScript>().GetMaxMP (gameObject.name);
        mana = maxMana;

        naturalRotation = transform.rotation;
    }
예제 #27
0
    // Update is called once per frame
    void Update()
    {
        if (Input.GetKey(KeyCode.E))
        {
            Destroy(GameObject.Find("PlayerSelectionData"));
            SceneManager.LoadScene("GameScene");
        }

        // Get the inputdevice that was most recently pressed
        InputDevice currentInput = InputManager.ActiveDevice;


        bool alreadyActive = false;



        // If X was pressed
        if (currentInput.Action1.WasPressed)
        {
            // Check to see if this player is already active
            foreach (PlayerSelection plr in players)
            {
                if (plr.input.GUID == currentInput.GUID)
                {
                    alreadyActive = true;
                }
            }

            // Don't add any more than 4 players
            if (players.Count >= 4)
            {
                alreadyActive = true;
            }

            if (!alreadyActive)
            {
                // Add the new player
                PlayerSelection newPlr = new PlayerSelection
                {
                    playerType = PlayerType.UNDECIDED,
                    input      = currentInput
                };

                GameObject playerCursor = GameObject.Find((playerCount + 1).ToString());
                Color      cursorColour = playerCursor.GetComponent <Image>().color;
                cursorColour.a = 1;

                CursorScript cursorScript = playerCursor.GetComponent <CursorScript>();
                playerCursor.GetComponent <Image>().color = cursorColour;

                cursorScript.player = newPlr;
                cursorScript.Yeet();
                cursorScript.playerNumber = playerCount;

                playerCursor.transform.SetParent(transform); // pull the cursor out of the playerindicator gameobject
                players.Add(newPlr);
                playerCount++;

                RefreshPlayerAvailabilities();
            }
        }


        if (readyToStart)
        {
            // If start button was pressed, start the game
            if (currentInput.Command.WasPressed && !starting)
            {
                starting = true;

                PreparePlayerSelectionObject();
                SceneManager.LoadScene("GameScene");
            }
        }
    }
예제 #28
0
 private void Start()
 {
     Invoke("DestroyProjectile", lifeTime);
     _player = GameObject.Find("Player").GetComponent <Player>();
     _cursor = GameObject.FindGameObjectWithTag("Cursor").GetComponent <CursorScript>();
 }
예제 #29
0
    //update teleportation controls
    public void UpdateTeleportation()
    {
        //allow the player to select a teleporter
        if (animState.IsName("PhasingOut"))
        {
            //if the player is invisible/intangible and has not started teleporting
            if (!GetComponent <Renderer>().enabled&& !GetComponent <TrailRenderer>().enabled)
            {
                //if the mouse has moved
                if (mouseMoved)
                {
                    Collider2D[] colliders;
                    //get the objects at the mouse point
                    if (Application.platform == RuntimePlatform.PSMPlayer)
                    {
                        colliders = Physics2D.OverlapPointAll(Camera.main.ScreenToWorldPoint(Input.GetTouch(0).position));
                    }
                    else
                    {
                        colliders = Physics2D.OverlapPointAll(Camera.main.ScreenToWorldPoint(Input.mousePosition));
                    }

                    //iterate through the colliders
                    foreach (Collider2D other in colliders)
                    {
                        //if the mouse is at a teleporter of the correct colour, it is the selected teleporter
                        if (other.tag == "Teleporter")
                        {
                            if (other.GetComponent <TeleportNodeScript>().colour == teleportColour)
                            {
                                selectedTeleporter = other.gameObject;
                            }
                        }
                    }
                }

                //get all the teleporters
                GameObject[]      teleporters       = GameObject.FindGameObjectsWithTag("Teleporter");
                List <GameObject> colourTeleporters = new List <GameObject>();

                //select the first teleporter of the correct colour
                foreach (GameObject teleporter in teleporters)
                {
                    if (teleporter.GetComponent <TeleportNodeScript>().colour == teleportColour)
                    {
                        colourTeleporters.Add(teleporter);
                    }
                }

                //if the axis has changed
                if (previousHorizontalAxis == 0.0f && Input.GetAxis("Horizontal") != 0.0f)
                {
                    //decrement the index
                    if (Input.GetAxis("Horizontal") < 0.0f)
                    {
                        teleporterIndex--;
                    }

                    //increment the index
                    if (Input.GetAxis("Horizontal") > 0.0f)
                    {
                        teleporterIndex++;
                    }

                    //ensure the index is within the bounds
                    if (teleporterIndex >= colourTeleporters.Count)
                    {
                        teleporterIndex = 0;
                    }
                    if (teleporterIndex < 0)
                    {
                        teleporterIndex = (colourTeleporters.Count - 1);
                    }

                    //set the selected teleporter
                    selectedTeleporter = colourTeleporters[teleporterIndex];
                }

                //make sure the cursor is at the correct position
                if (selectedTeleporter)
                {
                    CursorScript.CreateNewCursor(selectedTeleporter.transform.position, cursorPrefab);
                }

                //if the player presses action
                if ((Input.GetButtonDown("Action") || Input.GetMouseButtonDown(0) || (Input.touchCount > 0 && Input.GetTouch(0).phase == TouchPhase.Began)) && selectedTeleporter)
                {
                    //player is teleporting to the selected teleporter
                    teleportEndPosition = selectedTeleporter.transform.position;
                    teleportDirection   = teleportEndPosition - (Vector2)transform.position;

                    selectedTeleporter = null;

                    TrailRenderer trail = GetComponent <TrailRenderer>();
                    trail.enabled = true;

                    audio.loop = true;
                    audio.clip = teleportFlyClip;
                    audio.Play();

                    //remove the cursor
                    CursorScript.RemoveCursors();
                }
            }
        }

        //if the player is teleporting, move towards the target position
        if (teleportDirection != Vector2.zero)
        {
            transform.Translate(teleportDirection.normalized * teleportSpeed * Time.deltaTime);

            //if the player is close to the target position, set its position to the target
            if ((teleportEndPosition - (Vector2)transform.position).magnitude < 0.5f)
            {
                transform.position = teleportEndPosition;

                //start phasing in
                animator.SetBool("isTeleporting", true);

                teleportEndPosition = Vector2.zero;
                teleportDirection   = Vector2.zero;

                GetComponent <TrailRenderer>().enabled = false;
                renderer.enabled = true;

                audio.Stop();
                audio.PlayOneShot(teleportInClip);
            }
        }
    }
예제 #30
0
    public void ClientGrab(int grabbed_id, int player_id)
    {
        // Check if client is already holding dice or tokens
        bool holding_anything          = false;
        bool holding_anything_but_dice = false;

        foreach (GameObject grabbable in grabbable_objects)
        {
            GrabbableScript grabbable_script = grabbable.GetComponent <GrabbableScript>();
            if (grabbable_script.held_by_player_ == player_id)
            {
                holding_anything = true;
                if (!grabbable.GetComponent <DiceScript>())
                {
                    holding_anything_but_dice = true;
                }
            }
        }
        CursorScript cursor_script = null;

        foreach (GameObject cursor in cursor_objects)
        {
            if (cursor.GetComponent <CursorScript>().id() == player_id)
            {
                cursor_script = cursor.GetComponent <CursorScript>();
            }
        }
        // See if client can grab object given already-grabbed objects
        foreach (GameObject grabbable in grabbable_objects)
        {
            GrabbableScript grabbable_script = grabbable.GetComponent <GrabbableScript>();
            if (grabbable_script.id_ == grabbed_id)
            {
                if (grabbable_script.held_by_player_ == player_id)
                {
                    return;
                }
                if ((grabbable.GetComponent <DiceScript>() && !holding_anything_but_dice) ||
                    (grabbable.GetComponent <TokenScript>() && !holding_anything) ||
                    (grabbable.GetComponent <ParentTokenScript>() && !holding_anything) ||
                    (grabbable.GetComponent <DeckScript>() && !holding_anything) ||
                    (grabbable.GetComponent <CardScript>() && !holding_anything) ||
                    (grabbable.GetComponent <CoinScript>() && !holding_anything))
                {
                    grabbable_script.held_by_player_ = player_id;
                    if (grabbable.GetComponent <DiceScript>())
                    {
                        grabbable.GetComponent <DiceScript>().PickUpSound();
                    }
                    if (grabbable.GetComponent <CoinScript>())
                    {
                        grabbable.GetComponent <CoinScript>().PickUpSound();
                    }
                    if (grabbable.GetComponent <DeckScript>())
                    {
                        cursor_script.SetCardFaceUp((grabbable.transform.up.y > 0.0f));
                        cursor_script.SetCardRotated(GetRotateFromGrabbable(grabbable));
                        grabbable.GetComponent <DeckScript>().PickUpSound();
                    }
                    if (grabbable.GetComponent <CardScript>())
                    {
                        cursor_script.SetCardFaceUp((grabbable.transform.up.y < 0.0f));
                        cursor_script.SetCardRotated(GetRotateFromGrabbable(grabbable));
                        grabbable.GetComponent <CardScript>().PickUpSound();
                    }
                    if (grabbable.GetComponent <TokenScript>())
                    {
                        grabbable.GetComponent <TokenScript>().PickUpSound();
                    }
                    if (grabbable.GetComponent <ParentTokenScript>())
                    {
                        grabbable.GetComponent <ParentTokenScript>().PickUpSound();
                        cursor_script.SetCardRotated(GetRotateFromGrabbable(grabbable));
                    }
                    grabbable.rigidbody.mass = 0.2f;
                }
            }
        }
    }
예제 #31
0
 void Start()
 {
     cursor     = FindObjectOfType <CursorScript>();
     controller = GetComponent <NavMeshAgent>();
     controller.updateRotation = false;
 }
예제 #32
0
	// Use this for initialization
	void Start () {
        cursor = GameObject.Find("Cursor").GetComponent<CursorScript>();
        text = GetComponent<Text>();
	}
    void CreateTutorialWorld()
    {
        float          offset              = -.60f;
        List <Vector3> freeCoordinates     = new List <Vector3> ();
        List <Vector3> freeTileCoordinates = new List <Vector3> ();

        //create coordinate list
        for (int i = 0; i < 3; ++i)
        {
            for (int j = 0; j < 3; ++j)
            {
                if (i != 1 || j != 1)
                {
                    freeCoordinates.Add(new Vector3(i + offset, j - 3, 0));
                }
                freeTileCoordinates.Add(new Vector3(i + offset, j - 3, 1));
            }
        }

        //shuffle list
        for (int i = 0; i < freeCoordinates.Count; i++)
        {
            Vector3 temp        = freeCoordinates [i];
            int     randomIndex = Random.Range(0, freeCoordinates.Count);
            freeCoordinates [i]           = freeCoordinates [randomIndex];
            freeCoordinates [randomIndex] = temp;
        }


        int[]      villageSpritesInUse = new int[villageSprites.Length];
        GameObject shrine           = Resources.Load <GameObject> ("Prefabs/Environment/Shrine");
        GameObject graves           = Resources.Load <GameObject> ("Prefabs/Environment/Graves");
        GameObject forrest          = Resources.Load <GameObject> ("Prefabs/Environment/Forrest");
        GameObject ruins            = Resources.Load <GameObject> ("Prefabs/Environment/Ruins");
        GameObject tile             = Resources.Load <GameObject> ("Prefabs/Tile");
        GameObject playerVillage    = Resources.Load <GameObject> ("Prefabs/PlayerVillage");
        GameObject village          = Resources.Load <GameObject> ("Prefabs/AI/Village");
        GameObject cursor           = Resources.Load <GameObject> ("Prefabs/Cursor");
        GameObject goddessTree      = Resources.Load <GameObject> ("Prefabs/Environment/GaiaTree");
        GameObject shrineYard       = Resources.Load <GameObject> ("Prefabs/Environment/ShrineYard");
        GameObject umbralShard      = Resources.Load <GameObject> ("Prefabs/Environment/UmbralShard");
        GameObject plain            = Resources.Load <GameObject> ("Prefabs/Environment/Plains");
        GameObject plainEnhancement = Resources.Load <GameObject> ("Prefabs/Environment/PlainEnhancement");

        if (opponents > villageSprites.Length)
        {
            opponents = villageSprites.Length - 1;
        }
        if (opponents < 0)
        {
            opponents = 0;
        }

        //Create Tiles
        mapOccupation [1, 1] = 1;

        for (int i = 0; i < freeTileCoordinates.Count; i++)
        {
            Instantiate(tile, freeTileCoordinates[i], Quaternion.identity);
        }

        //spawn player
        int spriteSelect = Random.Range(0, villageSprites.Length);

        myPlayerVillage = Instantiate(playerVillage, freeCoordinates [0], Quaternion.identity) as GameObject;
        villageSpritesInUse [spriteSelect] = 1;
        myPlayerVillage.GetComponent <SpriteRenderer> ().sprite = villageSprites [spriteSelect];
        myPlayerVillage.GetComponent <PlayerVillageScript> ().SetName("");

        //spawn cursor
        myCursor       = Instantiate(cursor, new Vector3(freeCoordinates [0].x + .0005f, freeCoordinates [0].y + .001f, freeCoordinates [0].z), Quaternion.identity) as GameObject;
        myCursorScript = myCursor.GetComponent <CursorScript> ();
        //FIX CAST AS INT
        myCursorScript.locX = (int)(freeCoordinates [0].x + 1f);
        myCursorScript.locY = (int)(freeCoordinates [0].y + 3f);
        freeCoordinates.RemoveAt(0);


        //spawn villages
        for (int i = 0; i < opponents; ++i)
        {
            spriteSelect = Random.Range(0, villageSprites.Length);
            GameObject spawnVillage = Instantiate(village, freeCoordinates [0], Quaternion.identity) as GameObject;

            bool foundNewSprite = false;
            while (!foundNewSprite)
            {
                spriteSelect = Random.Range(0, villageSprites.Length);
                if (villageSpritesInUse[spriteSelect] != 1)
                {
                    foundNewSprite = true;
                    villageSpritesInUse [spriteSelect] = 1;
                }
            }

            spawnVillage.GetComponent <SpriteRenderer> ().sprite = villageSprites [spriteSelect];

            //assign random name
            spawnVillage.gameObject.GetComponent <VillageScript> ().SetName("(((them)))");
            villageSpritesInUse [spriteSelect] = 1;
            opponentList.Add(spawnVillage);
            freeCoordinates.RemoveAt(0);
        }


        //spawn forests
        int forrestNumber = Random.Range(8, 12);

        for (int i = 0; i < forrestNumber; ++i)
        {
            GameObject spawnForrest = Instantiate(forrest, freeCoordinates [0], Quaternion.identity) as GameObject;
            freeCoordinates.RemoveAt(0);
        }
        trees = GameObject.FindGameObjectsWithTag("Trees");

        //spawn graveyard
        int gravesNumber = Random.Range(2, 4);

        for (int i = 0; i < gravesNumber; ++i)
        {
            GameObject spawnGraves = Instantiate(graves, freeCoordinates [0], Quaternion.identity) as GameObject;
            freeCoordinates.RemoveAt(0);
        }


        //spawn shrine
        GameObject spawnShrine = Instantiate(shrine, freeCoordinates[0], Quaternion.identity) as GameObject;

        freeCoordinates.RemoveAt(0);

        //spawn ruins
        int ruinsNumber = Random.Range(8, 12);

        for (int i = 0; i < ruinsNumber; ++i)
        {
            GameObject spawnRuins = Instantiate(ruins, freeCoordinates [0], Quaternion.identity) as GameObject;
            freeCoordinates.RemoveAt(0);
        }


        //spawn goddess tree
        GameObject spawnGoddessTree = Instantiate(goddessTree, freeCoordinates[0], Quaternion.identity) as GameObject;

        freeCoordinates.RemoveAt(0);

        //spawn shrine yard
        int shrineYardNumber = Random.Range(1, 3);

        for (int i = 0; i < shrineYardNumber; ++i)
        {
            GameObject spawnShrineYard = Instantiate(shrineYard, freeCoordinates[0], Quaternion.identity) as GameObject;
            freeCoordinates.RemoveAt(0);
        }

        //spawn umbral shard
        GameObject spawnUmbralShard = Instantiate(umbralShard, freeCoordinates[0], Quaternion.identity) as GameObject;

        freeCoordinates.RemoveAt(0);

        //fill remaining squares with plains
        for (int i = 0; i < freeCoordinates.Count; ++i)
        {
            GameObject spawnPlains           = Instantiate(plain, freeCoordinates [i], Quaternion.identity) as GameObject;
            GameObject spawnPlainEnhancement = Instantiate(plainEnhancement, freeCoordinates [i], Quaternion.identity) as GameObject;
        }

        //find all trees for changing color during season
    }
    // Use this for initialization
    void Start()
    {
        usedMagicAttack = false;
        hpScript = gameObject.GetComponent<HealthScript>();
        lightColor = "White";
        uiScript = (CursorScript) GameObject.Find("Menu Cursor").GetComponent<CursorScript>();
        state = "Standby";
        prevLocation = transform.position;
        speed = 15.0f;
        successfullyAttacked = false;

        attackTimer = 0.0f;

        blackTimer = 0;

        dmgBox = (DamageBoxScript) GameObject.Find ("DamageBox").GetComponent<DamageBoxScript>();

        maxHealth = maxMana = 0.0f;
        maxHealth = GameObject.Find ("Menu Cursor").GetComponent<StatsScript>().GetMaxHP (gameObject.name);
        health = maxHealth;
        maxMana = GameObject.Find ("Menu Cursor").GetComponent<StatsScript>().GetMaxMP (gameObject.name);
        mana = maxMana;

        audioPlayer = gameObject.AddComponent<AudioSource>();
        if (gameObject.name == "Zebulon")
        {
            lasScript = gameObject.GetComponentInChildren<LaserScript>();
            lasScript.Hide();
        }
        cachedForward = transform.forward;
    }
 // Use this for initialization
 void Start()
 {
     uiScript = GameObject.Find ("Menu Cursor").GetComponent<CursorScript>();
     //Fade ();
 }
예제 #36
0
    public void UpdateInteraction()
    {
        //allow for player interactions
        if (Input.GetButtonDown("Action"))
        {
            //if the player is at a teleporter
            if (proxyType == ProxyObjectType.TELEPORTER && !isHanging)
            {
                if (!animState.IsName("PhasingOut") && !animState.IsName("PhasingIn"))
                {
                    //set the animation to phase out
                    animator.SetBool("isPhasing", true);

                    //prevent the player from moving
                    isRooted = true;
                    rigidbody2D.gravityScale = 0.0f;
                    teleporterIndex          = 0;
                    teleportColour           = proxyObject.GetComponent <TeleportNodeScript>().colour;

                    audio.PlayOneShot(teleportOutClip);
                }
            }

            //if the player is at a door and is grounded
            else if (proxyType == ProxyObjectType.DOOR && isGrounded)
            {
                //move the player to the door's exit
                Vector2 newPosition = proxyObject.GetComponent <DoorScript>().exit.transform.position;
                transform.position = newPosition;
            }

            else if (proxyType == ProxyObjectType.LEVER && isGrounded)
            {
                //switch the lever
                proxyObject.GetComponent <LeverScript>().Switch();
            }

            //if the player is at a grab point and is not grounded
            else if (proxyType == ProxyObjectType.GRABPOINT && !isGrounded)
            {
                if (!animState.IsName("PhasingOut") && !animState.IsName("PhasingIn"))
                {
                    //if the player is hanging already, release from the grab point
                    if (isHanging)
                    {
                        isRooted = false;

                        //if targetting another grab point, set it to the destination
                        if (targetedGrabPoint)
                        {
                            grabDestination = targetedGrabPoint;
                        }
                        else
                        {
                            //if not targetting a grab point, stop hanging
                            animator.SetBool("isHanging", false);
                            isHanging = false;
                            rigidbody2D.gravityScale = gravityScale;

                            //remove the old grabber
                            GameObject oldGrabber = GameObject.FindGameObjectWithTag("Grabber");
                            if (oldGrabber)
                            {
                                Destroy(oldGrabber);
                            }

                            //remove the old cursor
                            CursorScript.RemoveCursors();
                        }
                    }
                    else
                    {
                        //if not currently hanging, set the proxy grab point to the destination and start hanging
                        velocity                 = Vector2.zero;
                        rigidbody2D.velocity     = Vector2.zero;
                        rigidbody2D.gravityScale = 0.0f;

                        grabDestination = proxyObject;

                        animator.SetBool("isHanging", true);
                        isHanging = true;
                    }
                }
            }
        }

        //if the player is hanging
        if (isHanging)
        {
            //if not yet at the destination
            if ((Vector2)transform.position != (Vector2)grabDestination.GetComponent <GrabPointScript>().hangPoint.position)
            {
                //move towards the destination
                velocity = (Vector2)grabDestination.GetComponent <GrabPointScript>().hangPoint.position - (Vector2)transform.position;
                velocity.Normalize();
                velocity *= maxHorizontalSpeed;

                if (((Vector2)transform.position - (Vector2)grabDestination.GetComponent <GrabPointScript>().hangPoint.position).magnitude < 0.5f)
                {
                    transform.position = (Vector2)grabDestination.GetComponent <GrabPointScript>().hangPoint.position;
                }

                //remove the old grabber
                GameObject oldGrabber = GameObject.FindGameObjectWithTag("Grabber");
                if (oldGrabber)
                {
                    Destroy(oldGrabber);
                }

                //create a new grabber
                GameObject   grabber = (GameObject)GameObject.Instantiate(grabberPrefab, transform.position, Quaternion.identity);
                LineRenderer lr      = grabber.GetComponent <LineRenderer>();
                lr.SetPosition(0, grabber.transform.position);
                lr.SetPosition(1, grabDestination.transform.position);
                lr.SetWidth(0.1f, 0.1f);
                grabber.tag = "Grabber";
            }
            else
            {
                //if destination reached, root the player
                velocity             = Vector2.zero;
                rigidbody2D.velocity = Vector2.zero;
                isRooted             = true;
            }

            //if the player is pressing right
            if (Input.GetAxis("Horizontal") > 0.0f)
            {
                //look for a grab point to the right of the player
                Collider2D[] colliders = Physics2D.OverlapPointAll((Vector2)grabDestination.transform.position + new Vector2(5.0f, 0.0f));

                targetedGrabPoint = null;

                facingDirection.x = 1.0f;
                FaceRight(true);
                if (mindSeedSpawnPosition.x <= 0.0f)
                {
                    mindSeedSpawnPosition.x *= -1.0f;
                }

                foreach (Collider2D collider in colliders)
                {
                    //if grab point found
                    if (collider.tag == "GrabPoint")
                    {
                        //update the cursor
                        CursorScript.CreateNewCursor(collider.transform.position, cursorPrefab);

                        //set the grab point to the target
                        if (targetedGrabPoint != collider.gameObject)
                        {
                            targetedGrabPoint = collider.gameObject;
                        }
                    }
                }
            }
            //if the player is pressing left
            else if (Input.GetAxis("Horizontal") < 0.0f)
            {
                //look for a grab point to the left of the player
                Collider2D[] colliders = Physics2D.OverlapPointAll((Vector2)transform.position + new Vector2(-5.0f, 0.0f));

                targetedGrabPoint = null;

                facingDirection.x = -1.0f;
                FaceRight(false);
                if (mindSeedSpawnPosition.x >= 0.0f)
                {
                    mindSeedSpawnPosition.x *= -1.0f;
                }

                foreach (Collider2D collider in colliders)
                {
                    //if grab point found
                    if (collider.tag == "GrabPoint")
                    {
                        //update the cursor
                        CursorScript.CreateNewCursor(collider.transform.position, cursorPrefab);

                        //set the grab point to the target
                        if (targetedGrabPoint != collider.gameObject)
                        {
                            targetedGrabPoint = collider.gameObject;
                        }
                    }
                }
            }
            else
            {
                //remove the cursor
                CursorScript.RemoveCursors();
                targetedGrabPoint = null;
            }
        }
        else
        {
            //remove the old grabber
            GameObject oldGrabber = GameObject.FindGameObjectWithTag("Grabber");
            if (oldGrabber)
            {
                Destroy(oldGrabber);
            }
        }
    }
예제 #37
0
 void Awake()
 {
     i = this;
 }
예제 #38
0
 // Use this for initialization
 void Start()
 {
     cursor = Camera.main.GetComponent <CursorScript> ();
     gM_obj = GameObject.Find("GameManager").GetComponent <gameManager>();
 }