コード例 #1
0
 public void Activate(LemmingStateController lemming)
 {
     if (lemming == parentLemming)
     {
         particles.Play();
     }
 }
コード例 #2
0
 private void LemmingDie(LemmingStateController lemming)
 {
     if (isServer)
     {
         RpcLemmingDie(lemming.GetComponent <NetworkIdentity>());
     }
 }
コード例 #3
0
    //Assign Skills
    public bool assignSkill(LemmingStateController lemming)
    {
        if (skillsCounter[selectedSkill] <= 0)
        {
            return(false);
        }

        if (selectedSkill == Skill.Blocker)
        {
            blockerSelector.AttachToSomeone(lemming);
            isWaitingForBlockerConfirmation = true;
            return(false);
        }

        var localNetworkPlayer = LNetworkPlayer.LocalInstance;

        if (localNetworkPlayer == null)
        {
            Debug.LogError("no netowrk player");
            return(false);
        }

        localNetworkPlayer.CmdGiveSkill(lemming.GetComponent <NetworkIdentity>(), selectedSkill, lemming.transform.position);

        /* todo: give skill used to return false when trying to give skills and failed.
         *      With networked game, we need to change it to create skill given and skill failed events.
         */

        skillsCounter[selectedSkill]--;
        selectedSkill = Skill.None;
        GameEvents.Lemmings.LemmingUsedSkill.SafeInvoke(lemming);

        return(true);
    }
コード例 #4
0
    //Update Display Variables
    private void UpdateInfo(LemmingStateController lemming = null)
    {
        updateState(SkillsController.Instance.selectedSkill != Skill.None);
        int skillCount = SkillsController.Instance.getRemainingUses(skill);

        skillCountText.text       = skillCount.ToString();
        toggleButton.interactable = skillCount > 0;
    }
コード例 #5
0
 private void LemmingExit(LemmingStateController lemming)
 {
     Debug.Log("triggered local lemming exit");
     if (isServer)
     {
         Debug.Log("server triggered local lemming exit");
         RpcLemmingExit(lemming.GetComponent <NetworkIdentity>());
     }
 }
コード例 #6
0
ファイル: LemmingAI.cs プロジェクト: digonalmeida/lemmings3d
    private void Awake()
    {
        lemmingAnimationController            = GetComponent <LemmingAnimationController>();
        movementController                    = GetComponent <LemmingMovementController>();
        movementController.OnArrived         += OnArrivetAtWaypoint;
        movementController.OnGetNextWaypoint += OnGetNextWaypoint;

        stateController = GetComponent <LemmingStateController>();

        SetupStateMachine();
    }
コード例 #7
0
    private void RpcLemmingEnter(NetworkIdentity lemmingID)
    {
        if (lobbyPlayer.playerNum != LevelController.Instance.team)
        {
            return;
        }
        LemmingStateController lemming_ = lemmingID.GetComponent <LemmingStateController>();

        lemmingsOnScene[lemming_.Team].Add(lemming_);
        lemmingsSpawned[lemming_.Team]++;
        GameEvents.NetworkLemmings.LemmingSpawned.SafeInvoke(lemming_);
    }
コード例 #8
0
    private void UpdateInfo(LemmingStateController lemming)
    {
        if (LevelController.Instance.gameStateManager == null)
        {
            return;
        }

        outCount = LevelController.Instance.gameStateManager.lemmingsSpawned[LevelController.Instance.team];
        inCount  = LevelController.Instance.gameStateManager.lemmingsEnteredExit[LevelController.Instance.team];

        outText.text = outCount.ToString();
        inText.text  = outCount == 0 ? "0%" : (((int)(((float)inCount / (float)outCount) * 100)).ToString() + "%");
    }
コード例 #9
0
    private void RpcLemmingDie(NetworkIdentity lemmingID)
    {
        if (lobbyPlayer.playerNum != LevelController.Instance.team)
        {
            return;
        }
        LemmingStateController lemming_ = lemmingID.GetComponent <LemmingStateController>();

        lemmingsOnScene[lemming_.Team].Remove(lemming_);
        lemmingsDied[lemming_.Team]++;
        GameEvents.NetworkLemmings.LemmingDied.SafeInvoke(lemming_);
        lemmingID.GetComponent <LemmingActions>().EliminateLemming();
    }
コード例 #10
0
 private void Start()
 {
     //Initialize Variables
     targetPositionAddress   = Vector3Int.RoundToInt(transform.position);
     nextWaypoint            = this.transform.position;
     lemmingActions          = GetComponent <LemmingActions>();
     wallsLayerMask          = LayerMask.GetMask("Wall");
     lemmingsActionLayerMask = LayerMask.GetMask("LemmingAction");
     exitLayerMask           = LayerMask.GetMask("Exit");
     lemmingStateController  = GetComponent <LemmingStateController>();
     raycastHits             = new RaycastHit[1];
     overlapSphereHits       = new Collider[1];
     fallingBlocksCount      = 0;
 }
コード例 #11
0
    private void UpdateBar(LemmingStateController lemming)
    {
        var dict  = LevelController.Instance.gameStateManager.lemmingsEnteredExit;
        int count = dict[team];

        for (int i = 0; i < count; i++)
        {
            if (!units[units.Count - i - 1].on)
            {
                fill = count;
                UpdateFill(count);
            }
        }
    }
コード例 #12
0
    void RaycastForHighlightable()
    {
        if (EventSystem.current.IsPointerOverGameObject())
        {
            HighlightOff();
            return;
        }

        Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);

        Collider[] colliders = Physics.OverlapCapsule(ray.origin, ray.origin + ray.direction * distance, radius, highlaytableLayers, QueryTriggerInteraction.Collide);

        float distanceFromRay = float.MaxValue;
        bool  highlighted     = false;

        foreach (Collider col in colliders)
        {
            HighlightableObject highlightScript = col.gameObject.GetComponentInParent <HighlightableObject>();
            if (highlightScript != null && highlightScript.canBeHighlighted)
            {
                LemmingStateController lemming = highlightScript.GetComponent <LemmingStateController>();
                if (lemming != null)
                {
                    if (lemming.Team != playerTeam)
                    {
                        continue;
                    }
                }

                float angle = Vector3.Angle(ray.direction, (col.bounds.center - Camera.main.transform.position));
                float dist  = Mathf.Sin(Mathf.Deg2Rad * angle) * Vector3.Distance(col.bounds.center, Camera.main.transform.position);
                if (dist < distanceFromRay)
                {
                    distanceFromRay   = distance;
                    highlightedObject = highlightScript;
                    highlighted       = true;
                }
            }
        }

        if (highlighted && !isHighlighting)
        {
            HighlightOn();
        }
        else if (!highlighted && isHighlighting)
        {
            HighlightOff();
        }
    }
コード例 #13
0
    private void RpcLemmingExit(NetworkIdentity lemmingID)
    {
        if (lobbyPlayer.playerNum != LevelController.Instance.team)
        {
            return;
        }

        LemmingStateController lemming_ = lemmingID.GetComponent <LemmingStateController>();

        if (!lemmingsOnScene.ContainsKey(lemming_.Team))
        {
            lemmingsOnScene.Add(lemming_.Team, new List <LemmingStateController>());
        }
        lemmingsOnScene[lemming_.Team].Remove(lemming_);
        lemmingsEnteredExit[lemming_.Team]++;
        GameEvents.NetworkLemmings.LemmingReachedExit.SafeInvoke(lemming_);
    }
コード例 #14
0
    //Create Lemming
    private GameObject createLemming(LemmingSpawnInfo info)
    {
        GameObject obj = Instantiate(spawnable, info.position, Quaternion.identity);

        LemmingMovementController movController = obj.GetComponent <LemmingMovementController>();

        if (movController != null)
        {
            movController.SetDirection(info.startingMovementDirection);
            movController.SetForwardDirection(info.startingMovementDirection);
        }
        LemmingStateController stateController = obj.GetComponent <LemmingStateController>();

        if (stateController != null)
        {
            stateController.Team = info.team;
        }
        return(obj);
    }
コード例 #15
0
    public Direction CheckChangeDirectionOrders()
    {
        int hits = Physics.OverlapSphereNonAlloc(targetPositionAddress, 0.5f, overlapSphereHits, lemmingsActionLayerMask);

        for (int i = 0; i < hits; i++)
        {
            var hit = overlapSphereHits[i];
            LemmingStateController otherLemmingStateController = hit.GetComponentInParent <LemmingStateController>();

            if (otherLemmingStateController != null)
            {
                if (otherLemmingStateController.checkIsBlocker())
                {
                    var direction = otherLemmingStateController.BlockingDirection;
                    return(direction);
                }
            }
        }

        return(Direction.None);
    }
コード例 #16
0
    // Update is called once per frame
    void Update()
    {
        if (Input.GetMouseButtonDown(0))
        {
            // if has any selected skill
            if (SkillsController.Instance.selectedSkill != Skill.None)
            {
                if (SkillsController.Instance.isWaitingForBlockerConfirmation)
                {
                    if (!SkillsController.Instance.blockerSelector.someButtonHighlighted)
                    {
                        //Cancel Directioner
                        SkillsController.Instance.cancelSkill();
                        return;
                    }
                }
                else
                {
                    if (!HighlightPointer.Instance.isHighlighting)
                    {
                        SkillsController.Instance.cancelSkill();
                        return;
                    }
                }

                if (!SkillsController.Instance.isWaitingForBlockerConfirmation)
                {
                    if (HighlightPointer.Instance.isHighlighting)
                    {
                        LemmingStateController lemming = HighlightPointer.Instance.highlightedObject.GetComponent <LemmingStateController>();
                        SkillsController.Instance.assignSkill(lemming);
                    }
                }
            }
        }
    }
コード例 #17
0
 private void PlaySFX_LemmingDie(LemmingStateController lemming)
 {
     playSFX(lemmingDie.GetUniqueRandom());
 }
コード例 #18
0
 public void AttachToSomeone(LemmingStateController following)
 {
     followingLemming = following;
     Show();
 }
コード例 #19
0
 public void Detach()
 {
     followingLemming = null;
     Hide();
 }
コード例 #20
0
 private void Awake()
 {
     highlightableScript = GetComponent <HighlightableObject>();
     lemmingAIScript     = GetComponent <LemmingStateController>();
 }
コード例 #21
0
 void Awake()
 {
     particles     = GetComponent <ParticleSystem>();
     parentLemming = GetComponentInParent <LemmingStateController>();
 }
コード例 #22
0
 private void PlaySFX_GiveSkill(LemmingStateController lemming)
 {
     playSFX(giveSkill);
 }