Пример #1
0
 void MenuInteractionListener(PlayerInteraction_GamePhaseBehavior.MenuOptions inputOption)
 {
     Debug.Log("MenuInteractionListener");
     if (complete_trigger == TutorialCompletionTriggers.placeSignal || complete_trigger == TutorialCompletionTriggers.placeSemaphore)
     {
         if (inputOption == PlayerInteraction_GamePhaseBehavior.MenuOptions.button)
         {
             PlayerInteraction_GamePhaseBehavior.onMenuInteraction -= MenuInteractionListener;
             TriggerTutorialEventListener();
         }
         else if (inputOption == PlayerInteraction_GamePhaseBehavior.MenuOptions.semaphore)
         {
             PlayerInteraction_GamePhaseBehavior.onMenuInteraction -= MenuInteractionListener;
             TriggerTutorialEventListener();
         }
     }
 }
Пример #2
0
    public void PlaceGridElementAtLocation(Vector2 inputPosition, PlayerInteraction_GamePhaseBehavior.MenuOptions inputGridElement)
    {
        Vector3 testPosition = worldCamera.ScreenToWorldPoint(inputPosition);

        testPosition.z = 0;
        testPosition.x = Mathf.RoundToInt(testPosition.x);
        testPosition.y = Mathf.RoundToInt(testPosition.y);


        GridComponent c = new GridComponent();

        c.configuration = new Configuration();

        string type = "package_exchangepoint_00";

        switch (inputGridElement)
        {
        case PlayerInteraction_GamePhaseBehavior.MenuOptions.semaphore:
            type = "semaphore";
            break;

        case PlayerInteraction_GamePhaseBehavior.MenuOptions.button:
            type = "signal";
            break;
        }

        c.editable = "E";
        c.placedBy = "P";

        playerPlacedElementCount++;
        c.id = 9000 + playerPlacedElementCount;

        c.posX = (int)testPosition.x;
        c.posY = (int)testPosition.y;
        c.type = type;        //inputGridElement.ToString();
        c.configuration.link = -1;

        GameObject     gridElementInstance    = Instantiate(gridElementPrefab, testPosition, Quaternion.identity) as GameObject;
        SpriteRenderer instanceSpriteRenderer = gridElementInstance.GetComponent <SpriteRenderer>();

        instanceSpriteRenderer.sortingOrder = Constants.ComponentSortingOrder.basicComponents;

        instanceSpriteRenderer.sprite = GetSprite(c);

        gridElementInstance.transform.SetParent(gridContainer);

        //instanceSpriteRenderer.color = colorDictionary[color];
        GridObjectBehavior behavior = gridElementInstance.GetComponent <GridObjectBehavior>();

        if (type == "signal")
        {
            Signal_GridObjectBehavior signal_Behavior = gridElementInstance.AddComponent <Signal_GridObjectBehavior>();
            signal_Behavior.highlightObject = behavior.highlightObject;
            signal_Behavior.lineRenderer    = gridElementInstance.GetComponentInChildren <LineRenderer>();
            signal_Behavior.teleportTrail   = behavior.teleportTrail;
            Destroy(behavior);
            behavior = signal_Behavior;
        }

        behavior.component    = c;
        behavior.behaviorType = GridObjectBehavior.BehaviorTypes.component;

        Vector2 reverseYposition = new Vector2(c.posX, GameManager.Instance.GetLevelHeight() - c.posY);

        behavior.UpdateGridObjectPosition(reverseYposition);

        currentLevelObjects.Add(behavior);

        gridObjectLevelIDDictionary.Add(behavior.component.id, behavior);
        gridObjectLevelPositionDictionary.Add(behavior.transform.position, behavior);

        behavior.InitializeGridComponentBehavior();
    }