Example #1
0
    bool CheckIfEnemyHover()
    {
        EnemyDeselected?.Invoke();

        RaycastHit hit;
        Ray        ray = Camera.main.ScreenPointToRay(mouse.position.ReadValue());

        if (Physics.Raycast(ray, out hit, Mathf.Infinity, enemyLayer))
        {
            EnemySelected?.Invoke(hit.transform.position);
            return(true);
        }

        return(false);
    }
    private void ShakeEnded()
    {
        Selections selection;

        if (gameManager.EnemySelection != null)
        {
            selection = (Selections)gameManager.EnemySelection;
        }
        else
        {
            selection = (Selections)UnityEngine.Random.Range(0, 3);
        }

        spriteRenderer.sprite = Sprites.Inctance.RockPaperScissors[(int)selection];
        EnemySelected?.Invoke(selection);
    }
Example #3
0
 public void Select(GameObject entity)
 {
     if (entity.IsOwnedByPlayer())
     {
         this.selectedAlly = entity;
         this.allyFrame.gameObject.SetActive(true);
         this.allyFrame.transform.position = this.selectedAlly.transform.position;
         AllySelected?.Invoke(entity);
     }
     else
     {
         this.selectedEnemy = entity;
         this.enemyFrame.gameObject.SetActive(true);
         this.enemyFrame.transform.position = this.selectedEnemy.transform.position;
         this.enemyFrame.color = entity.IsOwnedByNeutral()
             ? Color.yellow.With(a: 0.25f) : Color.red.With(a: 0.25f);
         EnemySelected?.Invoke(entity);
     }
 }
Example #4
0
    private void State_OnChange(List <Colyseus.Schema.DataChange> changes)
    {
        foreach (var change in changes)
        {
            Debug.LogWarning(change.Value);
            if (change.Field == "player1Choice")
            {
                if (playernumber == 2)
                {
                    EnemySelected?.Invoke(Convert.ToInt32(change.Value));
                }
            }

            if (change.Field == "player2Choice")
            {
                if (playernumber == 1)
                {
                    EnemySelected?.Invoke(Convert.ToInt32(change.Value));
                }
            }
        }
    }
Example #5
0
    private void Players_OnChange(PlayerSchema value, string key)
    {
        Debug.Log("player state changed");
        if (value.SessionID != room.SessionId && value.Choice != -1)
        {
            Debug.Log("choice received of the enemy");
            EnemySelected?.Invoke((int)value.Choice);
        }

        if (value.SessionID != room.SessionId && value.User.Age != 0)
        {
            Debug.LogWarning(value.User.Name);

            EnemyInfoReceived?.Invoke(new User()
            {
                Age    = (int)value.User.Age,
                Name   = value.User.Name,
                Star   = value.User.Star,
                Gender = value.User.Gender
            });
        }
    }
 // Use this for initialization
 void Start()
 {
     Enemies = GameObject.FindGameObjectsWithTag("Enemy");
     _characterSelected = EnemyHolder.gameObject.GetComponent<EnemySelected>();
     text = GetComponent <Text> ();
 }
    // Use this for initialization
    void Start()
    {
        _enemySelected = EnemyHolder.gameObject.GetComponent<EnemySelected>();

        Enemies = GameObject.FindGameObjectsWithTag("Enemy");
    }
Example #8
0
 // Checks which selected items have changed and raises the corresponding events.
 // [wip] Order the statements according to call hierarchy?
 private void RaiseChangeEvents(ActiveItems a)
 {
     if (a.ActiveTileSet != ActiveTileSet || a.ActiveBackground != ActiveBackground)
     {
         LoadBackground();
     }
     if (a.ActiveTileSet != ActiveTileSet)
     {
         LoadRoomTiles(TileSetIndex);
         TileSetSelected?.Invoke(this, null);
     }
     if (a.ActiveScrollColor != ActiveScrollColor)
     {
         ScrollColorSelected?.Invoke(this, null);
     }
     if (a.ActiveEnemyType != ActiveEnemyType)
     {
         EnemyTypeSelected(this, null);
     }
     if (a.ActiveEnemyGfx != ActiveEnemyGfx)
     {
         EnemyGfxSelected?.Invoke(this, null);
     }
     if (a.ActiveEnemy != ActiveEnemy)
     {
         EnemySelected?.Invoke(this, null);
     }
     if (a.ActivePlmType != ActivePlmType)
     {
         PlmTypeSelected?.Invoke(this, null);
     }
     if (a.ActivePlm != ActivePlm)
     {
         PlmSelected?.Invoke(this, null);
     }
     if (a.ActiveDoor != ActiveDoor)
     {
         DoorSelected?.Invoke(this, null);
     }
     if (a.ActiveRoomState != ActiveRoomState)
     {
         RoomStateSelected?.Invoke(this, null);
         LevelDataSelected?.Invoke(this, null);
         PlmListChanged?.Invoke(this, new ListLoadEventArgs(PlmIndex));
         EnemyListChanged?.Invoke(this, new ListLoadEventArgs(EnemyIndex));
         EnemyGfxListChanged?.Invoke(this, new ListLoadEventArgs(EnemyGfxIndex));
         ScrollDataListChanged?.Invoke(this, new ListLoadEventArgs(ScrollDataIndex));
     }
     else if (a.ActiveLevelData != ActiveLevelData)
     {
         LevelDataSelected.Invoke(this, null);
     }
     if (a.ActiveRoom != ActiveRoom)
     {
         RoomSelected?.Invoke(this, null);
         RoomStateListChanged?.Invoke(this, new ListLoadEventArgs(RoomStateIndex));
         DoorListChanged?.Invoke(this, new ListLoadEventArgs(DoorIndex));
     }
     if (a.ActiveArea != AreaIndex)
     {
         AreaSelected?.Invoke(this, null);
         RoomListChanged?.Invoke(this, new ListLoadEventArgs(RoomIndex));
     }
     if (a.ActiveScrollData != ActiveScrollData)
     {
         ScrollDataSelected?.Invoke(this, null);
         var e = new LevelDataEventArgs()
         {
             AllScreens = true
         };
         LevelDataModified?.Invoke(this, e);
     }
     if (a.ActiveFx != ActiveFx)
     {
         FxSelected?.Invoke(this, null);
         FxDataListChanged?.Invoke(this, new ListLoadEventArgs(FxDataIndex));
     }
     if (a.ActiveFxData != ActiveFxData)
     {
         FxDataSelected?.Invoke(this, null);
     }
 }
 private void Colyseus_EnemySelected(int obj)
 {
     Debug.Log("broadcasting choice of the enemy!");
     EnemySelected?.Invoke((Selections)obj);
 }