Example #1
0
    private void SetTarget(LifeObjectCollider target)
    {
        LifeObjectCollider newLOC = target;

        if (target.GetPlayer() != MainScreenManager_GameScene.Instance.GetPlayer())
        {
            if (this.previousLOC != null)
            {
                previousLOC.EnableOutline(false);
            }
            if (this.previousSoldier != null)
            {
                previousSoldier.EnableOutline(false);
            }

            // Check if no soldiers before enabling outline?
            if (!target.GetPlayer().GetCardManager().GetDefenseManager().HasFrontDefense())
            {
                newLOC.EnableOutline(true);
            }
            else
            {
                newLOC.EnableOutline(false);
            }
            previousLOC     = newLOC;
            previousSoldier = null;
        }
    }
Example #2
0
    private void SetTarget(SoldierCollider target)
    {
        Soldier newTarget = target.GetSoldier();

        if (newTarget.GetPlayerOwner() != MainScreenManager_GameScene.Instance.GetPlayer() && newTarget.GetCardReference() != null)
        {
            if (this.previousSoldier != newTarget && this.previousSoldier != null)
            {
                this.previousSoldier.EnableOutline(false);
            }

            newTarget.EnableOutline(true);
            bool hasSupport = newTarget.GetBackup().GetCard() != null ? true : false;
            AttackManagerUI.Instance.GetEnemyCharacterFrame().LoadCard(newTarget.GetCardReference(), hasSupport);

            this.previousSoldier = newTarget;

            if (previousLOC != null)
            {
                this.previousLOC.EnableOutline(false);
            }

            this.previousLOC = null;
        }
    }
Example #3
0
    /// <summary>
    ///
    /// </summary>
    /// <param name="attacker"></param>
    /// <param name="bullet"></param>
    /// <param name="heartLOC"></param>
    /// <returns>True if attack is valid, false if not.
    public bool HandleDirectAttack(PlayerManager attacker, List <Card> bullets, LifeObjectCollider heartLOC)
    {
        bool validHit = heartLOC.IsHit(attacker);

        if (validHit)
        {
            return(true);
        }
        else
        {
            return(false);
        }
    }
Example #4
0
    private void RemoveTarget()
    {
        if (this.previousLOC != null)
        {
            previousLOC.EnableOutline(false);
        }
        if (this.previousSoldier != null)
        {
            previousSoldier.EnableOutline(false);
        }

        previousLOC     = null;
        previousSoldier = null;
    }
Example #5
0
    public void SetAttackMode(bool val)
    {
        this.inAttackMode = val;
        if (!val)
        {
            if (previousLOC != null)
            {
                previousLOC.EnableOutline(false);
            }
            if (previousSoldier != null)
            {
                previousSoldier.EnableOutline(false);
            }

            previousLOC     = null;
            previousSoldier = null;
        }
    }
Example #6
0
    // Update is called once per frame
    void Update()
    {
        PlayerManager curPlayer = MainScreenManager_GameScene.Instance.GetPlayer();

        RaycastHit hit;
        Ray        ray = new Ray(Camera.main.transform.position, Camera.main.transform.forward);

        Debug.DrawRay(ray.origin, ray.direction * 1000, Color.red, .2f);
        // If hit
        if (Physics.Raycast(ray, out hit, float.PositiveInfinity))
        {
            // If the AttackManager Panel is shown
            if (inAttackMode)
            {
                // If game object hit contains SoldierCollider.cs, enable the outline for the target soldier
                if (hit.collider.gameObject.GetComponent <SoldierCollider>() != null)
                {
                    Debug.Log("<color=red>Soldier HIT </color>");
                    SetTarget(hit.collider.gameObject.GetComponent <SoldierCollider>());
                }
                else if (hit.collider.GetComponent <LifeObjectCollider>() != null)
                {
                    LifeObjectCollider targetLOC = hit.collider.GetComponent <LifeObjectCollider>();
                    if (targetLOC.GetPlayer() != curPlayer)
                    {
                        Debug.Log("<color=red>targetLOC HIT </color>");
                        SetTarget(targetLOC);
                    }
                }
                else
                {
                    // If no hit during attack mode
                    RemoveTarget();
                }
            }
            //// If game object hit contains BackupMatCollider.cs, open the Backup Mat Drawer and flip all backup cards up.
            //else if (hit.collider.gameObject.GetComponent<BackupMatCollider>() != null) {
            //	//targetBackup = hit.collider.gameObject.GetComponent<SoldierBackupCollider>().GetSoldierBackup();
            //	if (bmcReference == null) {
            //		BackupMatCollider bmc = hit.collider.gameObject.GetComponent<BackupMatCollider>();
            //		if (bmc.GetPlayer() == curPlayer) {
            //			bmcReference = bmc;
            //			bmc.GetParent().OpenBackupMat(true);
            //		}
            //	}
            //	//curMatShown = 0f;
            //}
            //// If Backup mat is not hit and the backup mat is opened
            //else if (hit.collider.gameObject.GetComponent<SoldierBackupCollider>() == null && hit.collider.gameObject.GetComponent<BackupMatCollider>() == null && bmcReference != null) {
            //	curMatShown += Time.deltaTime;
            //	// If the backup mat has not been hit for X duration, hide the backup mat
            //	if (curMatShown >= backupMatShowDuration) {
            //		curMatShown = 0f;
            //		bmcReference.GetParent().OpenBackupMat(false);
            //		bmcReference = null;
            //	}
            //}
            // If player hit

            // If others hit
        }
        else
        {
            // If no hit
        }
    }
Example #7
0
    /// <summary>
    /// Locks on a target (if any) and stops the scanning process.
    /// Damages the target if applicable.
    /// </summary>
    public void LockOn()
    {
        if (!isScanning)
        {
            return;
        }

        PlayerManager curPlayer = MainScreenManager_GameScene.Instance.GetPlayer();

        Soldier            targetSoldier = this.GetTargetSoldier();
        LifeObjectCollider targetLOC     = this.GetTargetLifeCollider();

        // Know if the current target is the player heart or a soldier.
        if (targetSoldier != null)
        {
            Card targetCard = targetSoldier.GetCardReference();

            // The Target is a Soldier.
            if (targetCard != null && this.previousTarget != targetCard)
            {
                this.PlayFireSound(targetCard.GetCardSuit());

                // NEW: if exact, +1 move
                this.CleanKillBonus(targetSoldier);

                // The Current target Soldier is a valid target.
                Debug.Log("<color=green>SUCCESS! Target shot using " + GetLoadedBulletsSum() + "</color>");
                bool canFireAgain = CombatManager.Instance.HandleAttack(curPlayer, loadedBullets, targetSoldier);
                // insert fire animation here
                BackgroundRaycaster.Instance.ActivateParticle();

                if (canFireAgain)
                {
                    // Can Fire Again.
                    atkAnim.Again();
                    this.previousTarget    = targetCard;
                    cancelBtn.interactable = false;
                }
                else
                {
                    // Out of Shots or no more targets left
                    atkAnim.Hit();
                    curPlayer.ConsumeMove();                     // Subtract move from current player
                    UIHandCardManager.Instance.UnhideAllCards();
                    this.SuccessfulShot();
                    this.previousTarget = targetCard;
                    //ActionsLeftPanel.Instance.Show(); // EDITED (Candy)
                    ActionsLeftPanel.Instance.DelayedShow();
                    this.StopScan(1f); // Update delay time acc. to "Hit" animation prompt
                }
            }
            else
            {
                atkAnim.Miss();
            }
        }
        else if (targetLOC != null)
        {
            // The Target is a player heart.
            bool isSuccess = CombatManager.Instance.HandleDirectAttack(curPlayer, loadedBullets, targetLOC);
            if (isSuccess)
            {
                atkAnim.Hit();
                curPlayer.ConsumeMove();                 // Subtract move from current player
                // BackgroundRaycaster.Instance.ActivateParticle();
                UIHandCardManager.Instance.UnhideAllCards();
                this.SuccessfulShot();
                EventBroadcaster.Instance.PostEvent(EventNames.UI.SHOW_DIRECT_ATK_SUCCESS);
                this.StopScan();
                // TODO: instantly end the turn.
            }
            else
            {
                atkAnim.Miss();
            }
        }
        else
        {
            // There is no target
            atkAnim.Miss();
        }
    }