예제 #1
0
    private void LoadPlayerInventory()
    {
        // Get Player inventory
        GameObject logic  = GameObject.FindGameObjectWithTag("Logic");
        GameObject player = logic.GetComponent <S_Game_Logic>().Player;

        Assert.IsNotNull(player);
        GameObject            content   = GameObject.Find("Content");
        ControllableCharacter character = player.GetComponent <ControllableCharacter>();

        for (int i = 0; i < character.inventory.Items.Count; i++)
        {
            var wep = character.inventory.Items[i];
            if (wep.GetType() == typeof(Weapon))
            {
                GameObject entry = Instantiate(Entry, content.transform);
                // Get text of entry
                RectTransform rect       = entry.transform.GetComponent <RectTransform>();
                float         origHeight = rect.sizeDelta.y;
                float         offset     = -(rect.sizeDelta.y * i);
                rect.offsetMax = new Vector2(0, offset);
                rect.sizeDelta = new Vector2(0, origHeight);

                entry.transform.GetChild(0).GetComponent <Text>().text = ((Weapon)wep).name;
            }
        }
    }
예제 #2
0
 public void OnUse(ControllableCharacter character)
 {
     if (type == Type.BANDAGE)
     {
         character.health += 5;
     }
 }
예제 #3
0
    public HuntCommand(RaycastHit h, float killRadius)
    {
        this.target     = h.transform.GetComponent <ControllableCharacter>();
        this.killRadius = killRadius;

        target.MarkSelfAsTarget(true);
    }
    public override bool Execute(ControllableCharacter character)
    {
        if (character.MoveToLocation(targetLocation))
        {
            return(character.DropItem(item, targetLocation));
        }

        return(false);
    }
 public override bool Execute(ControllableCharacter character)
 {
     if (character.itemCount > 0)
     {
         Vector3 location = new Vector3(character.transform.position.x, 0.75f, character.transform.position.z);
         GameObject.Instantiate(itemPrefab, location, Quaternion.identity);
         character.itemCount--;
     }
     return(true);
 }
예제 #6
0
    public override bool Execute(ControllableCharacter character)
    {
        if (character.MoveToLocation(item.transform.position))
        {
            character.PickUpItem(item);
            return(true);
        }

        return(false);
    }
예제 #7
0
    public override bool Execute(ControllableCharacter character)
    {
        character.MoveToLocation(target.transform.position);

        if ((character.transform.position - target.transform.position).magnitude < killRadius)
        {
            return(character.KillTargetCharacter(target, killRadius));
        }

        return(false);
    }
예제 #8
0
 void SpawnPlayerCharacter(Vector3 position, Quaternion rotation)
 {
     if (playerCharacterPrefab != null)
     {
         playerCharacterInstance           = (ControllableCharacter)Instantiate(playerCharacterPrefab, position, rotation);
         playerCharacterInstance.Direction = playerCharacterInstance.transform.forward;
     }
     else
     {
         Debug.LogWarning("GameManager/SpawnPlayerCharacter (Vector3, Quaternion) : No playerCharacterPrefab is assigned. Not Spawning PlayerCharacter.");
     }
 }
예제 #9
0
 public void SwitchCharacter(ControllableCharacter ch)
 {
     ChosenCharacter = ch;
     for (int i = 0; i < Characters.Count; ++i)
     {
         if (Characters[i] == ch)
         {
             currentCharacterIndex = i;
             return;
         }
     }
 }
 void CheckForCharacterSelection()
 {
     // Check for left click
     if (Input.GetButtonDown("Fire1"))
     {
         RaycastHit hit;
         // If the component is null, it won't register as selected anyway
         if (MouseCast(out hit))
         {
             currentSelection = hit.transform.GetComponent <ControllableCharacter>();
         }
     }
 }
예제 #11
0
    public void Start()
    {
        LevelObjects               = new List <LevelObject>(GetComponentsInChildren <LevelObject>(true));
        Characters                 = new List <ControllableCharacter>(GetComponentsInChildren <ControllableCharacter>(true));
        currentCharacterIndex      = 0;
        ChosenCharacter            = Characters[currentCharacterIndex];
        GameManager.instance.Level = this;

        // By this point all cape pieces should be spawned.
        DropAllVerticalLayers();

        History = GetComponent <UndoHistorian>();
        CommitToUndoHistory();
    }
예제 #12
0
 void CheckForCharacterSelection()
 {
     if (Input.GetButtonDown("Fire1"))
     {
         RaycastHit hit;
         if (MouseCast(out hit))
         {
             //If hit character, select it, else deselects cc
             if (!action1)
             {
                 currentSelection = hit.transform.GetComponent <ControllableCharacter>();
             }
         }
     }
 }
    public bool KillTargetCharacter(ControllableCharacter character, float killRadius)
    {
        Vector3 positionDifference = character.transform.position - transform.position;

        if (positionDifference.magnitude < killRadius)
        {
            if (character || character.gameObject)
            {
                Destroy(character.gameObject);
            }

            return(true);
        }
        else
        {
            return(false);
        }
    }
예제 #14
0
    private void OnDirectionInput(Vector2Int direction)
    {
        Level level = GameManager.instance.Level;

        if (level != null)
        {
            Character = level.ChosenCharacter;
            if (Character != null && !level.Win)
            {
                Vector3Int worldDirection = GroundPlane.CameraRelativeDirectionToWorldCardinalDirection(
                    new Vector3(direction.x, 0.0f, direction.y),
                    GameManager.instance.Camera);
                if (Character.TryMove(worldDirection))
                {
                    level.CommitToUndoHistory();
                }
            }
        }
    }
예제 #15
0
    private void ProcessPointerInput()
    {
        Pointer p = Pointer.CreateOnPointerDown();

        if (p != null)
        {
            var        ray = p.GetRay(GameManager.instance.Camera);
            RaycastHit hitInfo;
            Physics.Raycast(ray, out hitInfo, 100.0f, 1 << LayerMask.NameToLayer("UI"));
            if (hitInfo.collider != null)
            {
                ControllableCharacter ch = hitInfo.collider.GetComponentInParent <ControllableCharacter>();
                if (ch != null)
                {
                    GameManager.instance.Level.SwitchCharacter(ch);
                }
            }
        }
    }
예제 #16
0
    public void SelectHero(ControllableCharacter selectedHero)
    {
        CurrentlySelectedHero = selectedHero;

        HUD.SelectedCharacterText.text = "Selected character: " + selectedHero.Name;

        string equipmentString = "Equipment: ";
        if(CurrentlySelectedHero.Equipment.Count == 0)
            equipmentString += "none";
        else
        {
            for(int i = 0; i < CurrentlySelectedHero.Equipment.Count - 1; i++)
            {
                equipmentString += CurrentlySelectedHero.Equipment[i].ToString() + ", ";
            }
            equipmentString += CurrentlySelectedHero.Equipment[CurrentlySelectedHero.Equipment.Count - 1].ToString();
        }
        HUD.Equipment.text = equipmentString;
    }
예제 #17
0
    public IEnumerator PlayTurn()
    {
        float minDist = 100000;

        foreach (ControllableCharacter character in GameManager.instance.ControllableCharacters)
        {
            float i = Vector3.Distance(transform.position, character.transform.position);

            if (i < minDist)
            {
                minDist = i;
                target  = character;
            }
        }

        pathfinder.seeker = transform;
        pathfinder.target = target.transform;

        while (energy > 0)
        {
            pathfinder.FindPath(transform.position, target.transform.position);
            Debug.Log(Vector3.Distance(transform.position, target.transform.position));
            if (Vector3.Distance(transform.position, target.transform.position) < attackRange)
            {
                StartCoroutine(Attack());
            }
            else
            {
                if (grid.path.Count > 0)
                {
                    yield return(StartCoroutine(WalkToNode(grid.path[0])));
                }
            }



            yield return(null);
        }
    }
예제 #18
0
 public void SwitchCharacter(int direction)
 {
     currentCharacterIndex += direction;
     WrapIndex.Wrap(ref currentCharacterIndex, Characters);
     ChosenCharacter = Characters[currentCharacterIndex];
 }
예제 #19
0
    public override bool Execute(ControllableCharacter character)
    {
        Vector3 offset = new Vector3(targetLocation.x, 1f, targetLocation.z);

        return(character.MoveToLocation(offset));
    }
 public override bool Execute(ControllableCharacter character)
 {
     GameObject.Destroy(targetObject.gameObject);
     character.itemCount++;;
     return(true);
 }
예제 #21
0
    public void UnselectHero()
    {
        CurrentlySelectedHero = null;

        HUD.SelectedCharacterText.text = "Selected character: none";
        HUD.Equipment.text = "Equipment: none";
    }
예제 #22
0
 public void CharacterActionEnd(ControllableCharacter hero)
 {
     hero.CurrentState = ECharacterState.Idle;
 }
 public void MarkTarget(ControllableCharacter target, bool marked)
 {
     target.huntingMark.SetActive(marked);
 }
 public override bool Execute(ControllableCharacter character)
 {
     return(character.MoveToLocation(targetLocation));
 }
예제 #25
0
 // Abstract class means that any child of baseCommand MUST override this function
 public abstract bool Execute(ControllableCharacter character);