// Use this for initialization
 void Awake()
 {
     if (instance == null)
     {
         instance = this;
     }
 }
Example #2
0
    void Start()
    {
        // Spawn followers.
        for (int i = 0; i < numberOfFollowers; i++)
        {
            minX = limitMarkerMin.position.x;
            minZ = limitMarkerMin.position.z;
            maxX = limitMarkerMax.position.x;
            maxZ = limitMarkerMax.position.z;

            xPosition = Random.Range(minX, maxX);
            zPosition = Random.Range(minZ, maxZ);

            FollowerManager newFollower = Instantiate(followerPrefab, new Vector3(xPosition, yPosition, zPosition), Quaternion.Euler(Vector3.up * Random.Range(0, 360)));
            newFollower.name = "Follower" + i;
        }

        // Spawn takers.
        for (int i = 0; i < numberOfTakers; i++)
        {
            xPosition = Random.Range(minX, maxX);
            zPosition = Random.Range(minZ, maxZ);

            TakerManager newTaker = Instantiate(takerPrefab, new Vector3(xPosition, yPosition, zPosition), Quaternion.Euler(Vector3.up * Random.Range(0, 360)));
            newTaker.randomCharisma = true;
            newTaker.name           = "Taker" + i;
        }
    }
Example #3
0
 // This method gets called by the runtime. Use this method to add services to the container.
 public void ConfigureServices(IServiceCollection services)
 {
     services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_1);
     LoadSettings();
     TwitterUserManager.RegisterManager(new TwitterUserManager(), new TwitterUserDataStore(SettingsHelper.Settings.CapitecFeed_ConnectionString));
     FollowerManager.RegisterManager(new FollowerManager(), new FollowerDataStore(SettingsHelper.Settings.CapitecFeed_ConnectionString));
 }
    void TakerOverride(int index)
    {
        FollowerManager followerManager = playerFollowers[index].GetComponentInParent <FollowerManager>();

        followerManager.overrideTarget = true;
        followerManager.SetFollowLeader(rivalTaker.transform);
    }
Example #5
0
        // Get follower references to set up equipment slots and assign index numbers to each slot
        private void RegisterEquipment()
        {
            Inventory playerInventory = Inventory.GetPlayerInventory();
            // Equipment followerEquipment = Equipment.GetEntityEquipment("Follower");

            FollowerManager followerManager = GameObject.FindWithTag("LevelManager").GetComponent <FollowerManager>();
            GameObject      followerGO;

            if (!followerManager.GetActiveFollowerObject(out followerGO))
            {
                return;
            }

            Equipment followerEquipment = followerGO.GetComponent <Equipment>();

            equipmentSlots ??= GetComponentsInChildren <EquipmentSlotUI>();
            Dictionary <EquipLocation, int> equipSlotLookup = new Dictionary <EquipLocation, int>();

            foreach (var slot in equipmentSlots)
            {
                EquipLocation equipLocation = slot.GetEquipLocation();
                if (equipSlotLookup.ContainsKey(equipLocation))
                {
                    equipSlotLookup[equipLocation]++;
                }
                else
                {
                    equipSlotLookup[equipLocation] = 0;
                }

                slot.Setup(playerInventory, followerEquipment, equipSlotLookup[equipLocation]);
            }
        }
    /*
     * public List<Transform> GetNearbyObjects(GameObject agent)
     * {
     *  //distanceToClosest = Mathf.Infinity;
     *  LayerMask layerMask = LayerMask.GetMask("Characters");
     *  List<Transform> context = new List<Transform>();
     *  // Get an array of all colliders in a the radius, using OverlapSphere.
     *  Collider[] contextColliders = Physics.OverlapSphere(agent.transform.position, sphereCurrentRadius);
     *  //Collider2D[] contextColliders = Physics2D.OverlapCircleAll(agent.transform.position, neighbourRadius);
     *
     *  foreach (Collider collider in contextColliders)
     *  {
     *      if ((currentState == State.FollowPlayer || currentState == State.FollowOther) && currentCharisma > agent.GetComponent<FollowerManager>().currentCharisma && currentLeader != agent.GetComponent<FollowerManager>().currentLeader)
     *      {
     *          SetAttackTarget(collider.gameObject.transform);
     *      }
     *      // Add all of the transforms of the colliders in the sphere, except this object's (agent's) transform.
     *      if (collider.gameObject != this)
     *      {
     *          //Debug.Log(agent.name + "in range of " + this.name);
     *          context.Add(collider.transform);
     *          float dist = Vector3.Distance(transform.position, collider.transform.position);
     *          if (dist < distanceToClosest)
     *          {
     *              distanceToClosest = dist;
     *              closestObject = collider;
     *          }
     *      }
     *  }
     *  return context;
     * }
     */

    private void RemoveFollower(FollowerManager activeFollower)
    {
        if (activeFollowers.Contains(activeFollower))
        {
            activeFollowers.RemoveAt(activeFollowers.IndexOf(activeFollower));
            ModifyCharisma(-1);
        }
    }
Example #7
0
        public void OnFollowerChange()
        {
            FollowerManager followerManager = GameObject.FindGameObjectWithTag("LevelManager").GetComponent <FollowerManager>();
            GameObject      followerGO;

            if (followerManager.GetActiveFollowerObject(out followerGO))
            {
                string sceneToLoad = "DescriptionTest";
                PopulateDescriptionText(sceneToLoad, followerGO);
            }
        }
Example #8
0
 void OnCollisionEnter(Collision collision)
 {
     if (collision.gameObject.layer == LayerMask.NameToLayer("Debris") && Time.time > _nextDamageTime &&
         collision.impulse.magnitude > _minimumImpact && FollowerManager.Followers.Count > 0)
     {
         var count = (int)(collision.impulse.magnitude * _impactToFollowerLossRatio);
         FollowerManager.LoseFollowers(count);
         _nextDamageTime = Time.time + _timeBetweenDamage;
     }
     if (FollowerManager.Followers.Count == 0)
     {
         GameObject.Find("Game Logic").GetComponent <GameLogic>().GameOver();
     }
 }
        public void OnFollowerChange()
        {
            FollowerManager followerManager = GameObject.FindGameObjectWithTag("LevelManager").GetComponent <FollowerManager>();

            CharacterClass followerClass;

            if (followerManager.GetActiveFollowerClass(out followerClass))
            {
                foreach (var skillDisplay in skillDisplays)
                {
                    skillDisplay.OnFollowerChange(followerClass);
                }
            }
        }
    // Use this for initialization
    void Start()
    {
        shotType = GetComponent <ShotType> ();

        //managerObj = GetComponent<Manager> ();
        managerObj = FindObjectOfType <Manager> ();

        //すでに生成されているオプションがある場合は削除
        if (FindObjectOfType <FollowerManager> ().getFollowersObj() != null)
        {
            FindObjectOfType <FollowerManager> ().destroyOldFollowers();
        }

        //TODO プレーヤーを取得
        if (Manager.p1 == true)
        {
            player = GameObject.Find("Player(Clone)");
        }
        else if (Manager.p2 == true)
        {
            player = GameObject.Find("Player2(Clone)");
        }
        else if (Manager.p3 == true)
        {
            player = GameObject.Find("Player3(Clone)");
        }
        else
        {
            player = GameObject.Find("Player(Clone)");
        }

        //オプション用のマネージャー設定
        flwMngObj = FindObjectOfType <FollowerManager> ();

        //数に合わせたオプションの作成開始
        flwMngObj.startFolloers();
        followersNum = flwMngObj.getFollowersNum();
        if (followersNum != flwMngObj.maxFollowers)
        {
            followersNum += 1;
        }
        flwMngObj.setFollowersNum(followersNum);
        buildInstance(followersNum);
        //Debug.Log (followersNum + "個のオプションを生成します。");

        // フォロワーのスピードを設定
        //followerVel = GetComponent<Spaceship>().speed; //public static
        StartCoroutine(Coroutine());
    }
 public SaveManager(AreaManager areaManager, FollowerManager followerManager,
                    NPCManager npcManager, BuildingManager buildingManager, BattleManager battleManager,
                    ItemDatabase itemDatabase, HuntingManager huntingManager, PlayfabManager playfabManager, PetManager petManager, HouseManager houseManager)
 {
     this.areaManager              = areaManager;
     this.followerManager          = followerManager;
     this.buildingManager          = buildingManager;
     this.battleManager            = battleManager;
     this.itemDatabase             = itemDatabase;
     this.npcManager               = npcManager;
     this.huntingManager           = huntingManager;
     this.playfabManager           = playfabManager;
     this.petManager               = petManager;
     this.houseManager             = houseManager;
     playfabManager.gameState      = gameState;
     playfabManager.messageManager = messageManager;
 }
    public void Convert(FollowerManager enemy, int damage)
    {
        enemy.ModifyLoyalty(-damage);
        //Debug.Log(name + " is converting " + enemy.gameObject.name);

        // After converting the target, gain charisma and loyalty and return to "Follow" state.
        if (enemy.currentLoyalty <= 0)
        {
            enemy.isConversionTarget = false;
            enemy.SetFollowLeader(currentLeader.transform);
            currentState = State.FollowPlayer;
            SetAttackTarget(null);
            ModifyCharisma(1);
            ModifyLoyalty(1);
            currentLeader.GetComponentInParent <SphereOfInfluence>().ModifyCharisma(1);
        }
    }
    // Use FixedUpdate for OverlapSphere.
    private void FixedUpdate()
    {
        agentsInSphere = Physics.OverlapSphere(transform.position, sphereRadius, viableTargets);

        // Get all of the agents in the sphere in each FixedUpdate.
        foreach (Collider agent in agentsInSphere)
        {
            FollowerManager agentFollower = agent.GetComponentInParent <FollowerManager>();
            // Select a new attack targt if: Not already attacking AND agent is a player, player's follower, leaderless follower, or innocent.
            if (currentState != State.Attack &&
                (agent.tag == "Player" ||
                 (agent.tag == "Innocent" && agent.GetComponentInParent <InnocentManager>().currentFaction != InnocentManager.Faction.Enemy) ||
                 (agent.tag == "Follower" && (agentFollower.currentLeader == null || (agentFollower.currentLeader != null && agentFollower.currentLeader.tag == "Player")))))
            {
                SetAttackTarget(agent.transform);
            }
        }
    }
Example #14
0
        public void OnFollowerChange()
        {
            // Get new follower reference and pass in updated equipment to Equipment Slots
            FollowerManager followerManager = GameObject.FindWithTag("LevelManager").GetComponent <FollowerManager>();
            GameObject      followerGO;

            if (!followerManager.GetActiveFollowerObject(out followerGO))
            {
                return;
            }

            Equipment followerEquipment = followerGO.GetComponent <Equipment>();

            foreach (var slot in equipmentSlots)
            {
                slot.OnFollowerChange(followerEquipment);
            }
        }
Example #15
0
    //========== メンバ変数 ==========
    //None

    IEnumerator Start()
    {
        // コンポーネントを取得
        followerMng = FindObjectOfType <FollowerManager> ();
        playerlife  = GetComponent <Life> ();
        managerObj  = FindObjectOfType <Manager> ();
        shotType    = GetComponent <ShotType> ();
        spaceship   = GetComponent <Spaceship> ();
        superShot   = GetComponent <SuperShot> ();
        audioObj    = FindObjectOfType <AudioManager> ();

        while (true)
        {
            int selectedShotType = shotType.getShotType();
            Attack(selectedShotType);
            // 弾をプレイヤーと同じ位置/角度で作成
            yield return(new WaitForSeconds(shotType.getPlayerShotDelay()));
        }
    }
Example #16
0
    // Start is called before the first frame update
    void Start()
    {
        renderer[0] = tilemap1.GetComponent <Renderer>();
        renderer[1] = tilemap2.GetComponent <Renderer>();

        standard[0] = renderer[0].material.shader;
        standard[1] = renderer[1].material.shader;

        bgcolor = GameObject.Find("Main Camera").GetComponent <Camera>().backgroundColor;

        for (int i = 0; i < renderer.Length; i++)
        {
            renderer[i].material.shader = black;
            renderer[i].material.SetColor("_Color", bgcolor);
        }


        fm = gameObject.GetComponent <FollowerManager>();
    }
Example #17
0
        public void SlotSetup(FollowerManager manager, int slotNumber)
        {
            followerManager       = manager;
            slot                  = slotNumber;
            layout.preferredWidth = (parentRect.rect.width - 20) / 2;

            GameObject followerGO = followerManager.GetFollowerObject(slot);

            if (followerGO == null)
            {
                return;
            }

            NPCInfo info = followerGO.GetComponent <NPCInfo>();

            classText.text    = (followerManager.GetFollowerClass(slot) == "Priest") ? "Priest" : "Witch Doctor";
            followerName.text = info.GetCharacterInfo("name");
            rankText.text     = info.GetCharacterInfo("rank");
            jobText.text      = GetPositionToDisplay();
            hungerText.text   = GetHungerDisplay(followerGO.GetComponent <Fullness>().GetPercentage());
        }
        private void PopulateSkillInfo()
        {
            attackStats ??= attackDB.GetAttackStat(atkName);

            FollowerManager followerManager = GameObject.FindGameObjectWithTag("LevelManager").GetComponent <FollowerManager>();
            CharacterClass  followerClass;

            if (followerManager.GetActiveFollowerClass(out followerClass))
            {
                if (skillDescription == null)
                {
                    skillDescription    = new string[4];
                    skillDescription[0] = attackStats.Description;
                    skillDescription[1] = "Mana Cost: " + attackStats.Cost.ToString();
                    skillDescription[2] = "Cast Time: " + attackStats.CastTime.ToString();
                    skillDescription[3] = "Cooldown: " + attackStats.Cooldown.ToString();
                }

                ClassSkillCheck(followerClass);
            }
        }
    public void ConvertToFollowSelf(FollowerManager target, int damage)
    {
        if (target.isTraitor == true && currentCharisma > target.currentCharisma)
        {
            target.isTraitor = false;
        }

        target.ModifyLoyalty(-damage);

        if (target.currentLoyalty <= 0)
        {
            enemyTarget = null;
            //Debug.Log(target.name + " follow " + transform.name + " before.");
            //target.ChangeMaterial(clothes, traitorFollowerMaterial);
            target.enemyTarget = null;
            target.SetFollowLeader(this.transform);
            //Debug.Log(target.name + " follow " + transform.name + " after.");
            ModifyCharisma(1);
            ModifyLoyalty(1);

            if (currentLeader.GetComponentInParent <SphereOfInfluence>() != null)
            {
                currentLeader.GetComponentInParent <SphereOfInfluence>().LoseFollower(target.gameObject);
            }
            else if (currentLeader.GetComponentInParent <FollowerManager>() != null)
            {
                currentLeader.GetComponentInParent <FollowerManager>().RemoveFollower(target);
            }
            //currentLeader.GetComponentInParent<SphereOfInfluence>().ModifyCharisma(-1);

            // Add follower to list of followers.
            if (activeFollowers.Contains(target) == false)
            {
                activeFollowers.Add(target);
            }

            // Reset the convert cooldown timer.
            convertCooldown = initialConvertCooldown;
        }
    }
    void ConvinceInRadius(float radius)
    {
        /*
         * if (currentEnergy >= 1)
         * {
         *  currentEnergy -= 1;
         * }
         */

        LayerMask layerMask = LayerMask.GetMask("Characters");

        Collider[] agentsInSphere = Physics.OverlapSphere(transform.position, radius, layerMask);
        foreach (Collider agent in agentsInSphere)
        {
            FollowerManager followerScript = agent.GetComponentInParent <FollowerManager>();

            if (agent.tag == "Follower" && currentEnergy > 0 && followerScript.currentCharisma < currentCharisma)
            {
                followerScript.SetFollowLeader(this.transform);
            }
        }
    }
    void Update()
    {
        if (minigameActive == true)
        {
            if (Input.GetMouseButtonDown(0))
            {
                Ray        ray = Camera.main.ScreenPointToRay(Input.mousePosition);
                RaycastHit hit;

                if (Physics.Raycast(ray, out hit, 100))
                {
                    if (hit.transform.gameObject.tag == "Follower" && hit.transform.GetComponentInParent <FollowerManager>().currentState == FollowerManager.State.FollowOther)
                    {
                        FollowerManager followerManager = hit.transform.GetComponentInParent <FollowerManager>();
                        Debug.Log("Clicked on " + hit.transform.gameObject.name);

                        followerManager.overrideTarget = true;
                        followerManager.SetFollowLeader(player.transform);
                    }
                }
            }

            takerClickTime -= Time.deltaTime;
            if (takerClickTime <= 0)
            {
                //Debug.Log("Click");

                if (playerFollowers.Count > 0)
                {
                    int indexNumber = Random.Range(0, playerFollowers.Count);
                    Debug.Log(indexNumber);
                    TakerOverride(indexNumber);
                }

                takerClickTime = takerClickMaxTime;
            }
        }
    }
Example #22
0
 public string GetSaveString(AreaManager areaManager, FollowerManager followerManager, NPCManager npcManager, BuildingManager buildingManager, BattleManager battleManager)
 {
     return(GetSaveStringEncrypted(areaManager, followerManager, npcManager, buildingManager, battleManager, true));
 }
Example #23
0
    public string GetSaveStringEncrypted(AreaManager areaManager, FollowerManager followerManager, NPCManager npcManager, BuildingManager buildingManager, BattleManager battleManager, bool encrypt)
    {
        int    pos  = 0;
        string data = "";

        //Bank 0
        data += "" + GetPlayerBank().GetInventory().ToString();
        pos++;
        //Skills 1
        data += "#" + GetPlayer().GetSkillString();
        pos++;
        //Inventory 2
        data += "#" + GetPlayerInventory().ToStringSorted();
        pos++;
        //Areas 3
        data += "#" + areaManager.SaveAreas();
        pos++;
        //Followers 4
        data += "#" + followerManager.ToString();
        pos++;
        //HP 5
        data += "#" + GetPlayer().CurrentHP.ToString();
        pos++;
        //ActiveFollower 6
        if (GetPlayer().activeFollower != null)
        {
            data += "#" + GetPlayer().activeFollower.id;
        }
        else
        {
            data += "#";
        }
        pos++;
        //Recipes 7
        data += "#";

        /*foreach (string s in GetPlayer().GetRecipes())
         * {
         *  data += s + "/";
         * }*/
        pos++;
        //EquippedItems 8
        data += "#";
        foreach (KeyValuePair <GameItem, int> pair in GetPlayerInventory().GetEquippedItems())
        {
            data += pair.Key.Id + "/";
        }
        pos++;
        //Settings 9
        data += "#";
        data += isSplitView.ToString();
        data += ",";
        data += compactBankView.ToString();
        data += ",";
        data += expensiveItemThreshold;
        data += ",";
        data += totalKills;
        data += ",";
        data += PetShopUnlocked.ToString();
        data += ",";
        data += autoBuySushiSupplies.ToString();
        data += ",";
        data += totalCoinsEarned;
        data += ",";
        data += totalDeaths;
        pos++;
        //NPC data 10
        data += "#";
        data += npcManager.GetNPCData();
        pos++;
        //Sushi House Data 11
        data += "#";
        data += sushiHouseRice + "," + sushiHouseSeaweed;
        pos++;
        //Tannery Data 12
        data += "#";
        foreach (Building b in buildingManager.GetBuildings())
        {
            if (b.Salt > 0)
            {
                data += "" + b.ID + "," + b.Salt + "/";
            }
        }
        pos++;
        //Tannery Slot Data 13
        data += "#";
        foreach (Building b in buildingManager.GetBuildings())
        {
            if (b.IsTannery)
            {
                data += b.ID + ">";
                foreach (TanningSlot slot in b.TanneryItems)
                {
                    data += slot.GetString() + "_";
                }
                data += "@";
            }
        }
        pos++;
        //GameState.isHunting 14
        data += "#";
        data += isHunting.ToString() + ",";
        data += huntingAreaID + ",";
        data += huntingStartTime.ToString() + ",";
        data += huntingEndTime.ToString();
        pos++;
        //Bank Tabs 15
        data += "#";
        data += GetPlayerBank().GetTabsString();
        pos++;
        //Pets 16
        data += "#";
        data += GetPlayer().GetPetString();
        pos++;
        //KC 17
        data += "#";
        data += GetKCString();
        pos++;
        //Dojos 18
        data += "#";
        data += battleManager.GetDojoSaveData();
        pos++;
        if (encrypt)
        {
            data = Encryptor.EncryptToString(data);
        }

        return(data);
    }
Example #24
0
 private void Start()
 {
     followerManager = GetComponentInParent <FollowerManager>();
 }
    // Use FixedUpdate for OverlapSphere.
    private void FixedUpdate()
    {
        sphereCurrentRadius = Mathf.Min(sphereInitialRadius + currentCharisma, sphereMaxRadius);
        agentsInSphere      = Physics.OverlapSphere(transform.position, sphereCurrentRadius, characterLayers);

        // Get all of the agents in the sphere in each FixedUpdate.
        foreach (Collider agent in agentsInSphere)
        {
            //if (agent.gameObject.layer == followerLayer)
            if (agent.CompareTag("Follower"))
            {
                FollowerManager agentFollower = agent.GetComponentInParent <FollowerManager>();

                // Attack conditions:
                if (currentState != State.Attack && currentLeader != null && agentFollower.gameObject != this.gameObject &&
                    // If this is a Player follower AND the agent is set as isAttackTarget.
                    ((currentLeader.CompareTag("Player") && agentFollower.isAttackTarget == true && startBetrayal == false) ||
                     // If this is a Player follower AND agent is not a player follower AND agent is set as isConversionTarget.
                     (currentLeader.CompareTag("Player") && agentFollower.currentLeader != null && agentFollower.currentLeader.tag != "Player" && agentFollower.isConversionTarget == true) ||
                     // If this is a player follower, attack Taker followers.
                     (currentLeader.CompareTag("Player") && agentFollower.currentLeader != null && agentFollower.currentLeader.CompareTag("Taker")) ||
                     // If this is a traitor that has more followers than the player, attack the player.
                     (isTraitor == true && startBetrayal == true && agentFollower.currentLeader != null && agentFollower.currentLeader.CompareTag("Player")) ||
                     // Attack any follower attacking this entity.
                     (agentFollower.enemyTarget != null && agentFollower.enemyTarget == this.gameObject) ||
                     // Attack any follower attacking this entity's leader, UNLESS this entity is a traitor.
                     (currentLeader.CompareTag("Player") && agentFollower.enemyTarget != null && agentFollower.enemyTarget == currentLeader && startBetrayal == false) ||
                     // If this is a Taker follower, attack player followers.
                     (currentLeader.CompareTag("Taker") && agentFollower.currentLeader != null && agentFollower.currentLeader.CompareTag("Player"))))
                {
                    SetAttackTarget(agent.transform);
                }
                // If this is a traitor, select a non-traitor player follower to attack.
                else if (currentState != State.Attack && currentLeader != null && agentFollower.gameObject != this.gameObject &&
                         isTraitor == true && startBetrayal == false && agentFollower.currentLeader != null && agentFollower.currentLeader.CompareTag("Player") &&
                         agentFollower.isTraitor == false && convertCooldown <= 0)
                {
                    Debug.Log(this.name + " converts " + agent.name);
                    agent.GetComponentInParent <FollowerManager>().isConversionTarget = true;
                    //SetConversionTarget(agent.transform);
                    SetAttackTarget(agent.transform);
                }

                // If this is a traitor with higher charisma that other traitors, convert them and their followers to follow this.
                else if (isTraitor == true && agentFollower.isTraitor == true && currentCharisma > agentFollower.currentCharisma)
                {
                    agentFollower.isTraitor = false;

                    /*
                     * foreach (FollowerManager traitorFollower in agentFollower.activeFollowers)
                     * {
                     *  ConvertToFollowSelf(traitorFollower, 100);
                     * }
                     * ConvertToFollowSelf(agentFollower, 100);
                     */
                }
            }

            // If this is one of the player's followers, also attack any Innocents in range (MUWAHAHAHA), and enemies.
            else if (currentState != State.Attack && currentLeader != null && currentLeader.CompareTag("Player") &&
                     ((agent.CompareTag("Innocent") && agent.GetComponentInParent <InnocentManager>().currentFaction == InnocentManager.Faction.Enemy) ||
                      agent.CompareTag("Enemy")))
            {
                Debug.Log(this.name + " attack innocent or enemy " + agent);
                SetAttackTarget(agent.transform);
            }

            // If the traitor has more followers than the player, attack the player.
            if (isTraitor == true && currentLeader != null && activeFollowers.Count >= player.GetComponentInParent <SphereOfInfluence>().activeFollowers.Count * 0.66)
            {
                startBetrayal = true;
                // If betrayal has started and there are no other eligible targets, traitor attacks the player.
                if (currentState != State.Attack)
                {
                    SetAttackTarget(player.transform);
                }

                // All traitor followers attack the player.
                foreach (FollowerManager follower in activeFollowers)
                {
                    if (follower != null && follower.currentState != State.Attack)
                    {
                        Debug.Log(this.name + " attack player " + agent);
                        follower.SetAttackTarget(player.transform);
                    }
                }
            }
        }
    }
    private void OnCollisionStay(Collision collision)
    {
        // On collision, inflict damage on the enemy target, only if colliding with the enemy target.
        //if (currentState == State.Attack && enemyTarget != null && collision.gameObject.name == enemyTarget.name)
        if (currentState == State.Attack && enemyTarget != null && collision.gameObject.layer == enemyTarget.gameObject.layer)
        {
            /*
             * collisionText.text = collision.gameObject.name.ToString();
             * targetText.text = enemyTarget.name.ToString();
             * Debug.Log(this.name + " collision GO " + collision.gameObject.name);
             * Debug.Log(this.name + " enemyTarget " + enemyTarget.name);
             */

            FollowerManager enemyFollower = enemyTarget.GetComponentInParent <FollowerManager>();
            // Damage the target every X seconds (attackTimer), then start a cooldown.
            attackCurrentTime -= Time.deltaTime;
            if (attackCurrentTime <= 0)
            {
                if (enemyTarget.tag != "Follower")
                {
                    // Damage the target on collision.
                    Attack(collision.gameObject.GetComponent <HitPointsManager>(), attackDamage);
                    attackCurrentTime = attackTimer;
                    Debug.Log(this.name + " attacks " + enemyTarget + ", " + enemyTarget.name);
                }
                else if (enemyTarget.CompareTag("Follower") && collision.gameObject.name == enemyTarget.name && enemyFollower.isConversionTarget == false
                         //&& ((enemyFollower.currentLeader != currentLeader && enemyFollower.isConversionTarget == false)
                         && (enemyFollower.currentLeader != currentLeader ||
                             (enemyFollower.currentLeader == currentLeader && enemyFollower.isAttackTarget == true) ||
                             (enemyFollower.currentLeader == currentLeader && enemyFollower.isTraitor && enemyFollower.currentState == State.Attack) ||
                             (enemyFollower.currentLeader == currentLeader && isTraitor == true) ||
                             enemyFollower.enemyTarget == this.transform))
                {
                    // Damage the target on collision. Damage = Base damage + killCount.
                    Attack(collision.gameObject.GetComponent <HitPointsManager>(), attackDamage);
                    attackCurrentTime = attackTimer;
                    Debug.Log("Attack damage " + attackDamage);
                }
                // Attack to convert of this is a traitor and the target is in collision range.
                else if (currentState == State.Attack && enemyTarget.CompareTag("Follower") && enemyFollower.isConversionTarget == true && collision.gameObject.name == enemyTarget.name)
                {
                    //Convert(collision.gameObject.GetComponentInParent<FollowerManager>(), convertDamage);
                    ConvertToFollowSelf(collision.gameObject.GetComponentInParent <FollowerManager>(), convertDamage);
                    attackCurrentTime = attackTimer;
                    Debug.Log("Convert damage " + convertDamage);
                }
            }
        }
        else if (enemyTarget == null && isTraitor == true && collision.gameObject.CompareTag("Follower") &&
                 currentLeader == collision.gameObject.GetComponentInParent <FollowerManager>().currentLeader&&
                 collision.gameObject.GetComponentInParent <FollowerManager>().isTraitor == false)
        {
            attackCurrentTime -= Time.deltaTime;
            if (attackCurrentTime <= 0 && collision.gameObject.GetComponentInParent <FollowerManager>().currentLoyalty > 0)
            {
                ConvertToFollowSelf(collision.gameObject.GetComponentInParent <FollowerManager>(), convertDamage);
                attackCurrentTime = attackTimer;
                //Debug.Log("Convert damage " + convertDamage);
            }
        }
    }
 public FollowerController(FollowerManager manager)
 {
     this.manager = manager;
 }
Example #28
0
    public string GetSaveString(AreaManager areaManager, FollowerManager followerManager, NPCManager npcManager, BuildingManager buildingManager)
    {
        string data = "";

        //Bank 0
        data += "" + GetPlayerBank().GetInventory().ToString();
        //Skills 1
        data += "#" + GetPlayer().GetSkillString();
        //Inventory 2
        data += "#" + GetPlayerInventory().ToString();
        //Areas 3
        data += "#" + areaManager.SaveAreas();
        //Followers 4
        data += "#" + followerManager.ToString();
        //HP 5
        data += "#" + GetPlayer().CurrentHP.ToString();
        //ActiveFollower 6
        if (GetPlayer().activeFollower != null)
        {
            data += "#" + GetPlayer().activeFollower.id;
        }
        else
        {
            data += "#";
        }
        //Recipes 7
        data += "#";
        foreach (string s in GetPlayer().GetRecipes())
        {
            data += s + "/";
        }
        //EquippedItems 8
        data += "#";
        foreach (KeyValuePair <GameItem, int> pair in GetPlayerInventory().GetEquippedItems())
        {
            data += pair.Key.Id + "/";
        }
        //Settings 9
        data += "#";
        data += isSplitView.ToString();
        data += ",";
        data += compactBankView.ToString();
        //NPC data 10
        data += "#";
        data += npcManager.GetNPCData();
        //Sushi House Data 11
        data += "#";
        data += sushiHouseRice + "," + sushiHouseSeaweed;
        //Tannery Data 12
        data += "#";
        foreach (Building b in buildingManager.GetBuildings())
        {
            if (b.Salt > 0)
            {
                data += "" + b.ID + "," + b.Salt + "/";
            }
        }
        //Tannery Slot Data 13
        data += "#";
        foreach (Building b in buildingManager.GetBuildings())
        {
            if (b.IsTannery)
            {
                data += b.ID + ">";
                foreach (TanningSlot slot in b.TanneryItems)
                {
                    data += slot.GetString() + "_";
                }
                data += "@";
            }
        }
        //GameState.isHunting 14
        data += "#";
        data += isHunting.ToString() + ",";
        data += huntingAreaID + ",";
        data += huntingStartTime.ToString() + ",";
        data += huntingEndTime.ToString();
        data  = Encryptor.EncryptToString(data);
        return(data);
    }
Example #29
0
    public string GetSaveString(AreaManager areaManager, FollowerManager followerManager, NPCManager npcManager, BuildingManager buildingManager)
    {
        int    pos  = 0;
        string data = "";

        try
        {
            //Bank 0
            data += "" + GetPlayerBank().GetInventory().ToString();
            pos++;
            //Skills 1
            data += "#" + GetPlayer().GetSkillString();
            pos++;
            //Inventory 2
            data += "#" + GetPlayerInventory().ToString();
            pos++;
            //Areas 3
            data += "#" + areaManager.SaveAreas();
            pos++;
            //Followers 4
            data += "#" + followerManager.ToString();
            pos++;
            //HP 5
            data += "#" + GetPlayer().CurrentHP.ToString();
            pos++;
            //ActiveFollower 6
            if (GetPlayer().activeFollower != null)
            {
                data += "#" + GetPlayer().activeFollower.id;
            }
            else
            {
                data += "#";
            }
            pos++;
            //Recipes 7
            data += "#";
            foreach (string s in GetPlayer().GetRecipes())
            {
                data += s + "/";
            }
            pos++;
            //EquippedItems 8
            data += "#";
            foreach (KeyValuePair <GameItem, int> pair in GetPlayerInventory().GetEquippedItems())
            {
                data += pair.Key.Id + "/";
            }
            pos++;
            //Settings 9
            data += "#";
            data += isSplitView.ToString();
            data += ",";
            data += compactBankView.ToString();
            data += ",";
            data += expensiveItemThreshold;
            pos++;
            //NPC data 10
            data += "#";
            data += npcManager.GetNPCData();
            pos++;
            //Sushi House Data 11
            data += "#";
            data += sushiHouseRice + "," + sushiHouseSeaweed;
            pos++;
            //Tannery Data 12
            data += "#";
            foreach (Building b in buildingManager.GetBuildings())
            {
                if (b.Salt > 0)
                {
                    data += "" + b.ID + "," + b.Salt + "/";
                }
            }
            pos++;
            //Tannery Slot Data 13
            data += "#";
            foreach (Building b in buildingManager.GetBuildings())
            {
                if (b.IsTannery)
                {
                    data += b.ID + ">";
                    foreach (TanningSlot slot in b.TanneryItems)
                    {
                        data += slot.GetString() + "_";
                    }
                    data += "@";
                }
            }
            pos++;
            //GameState.isHunting 14
            data += "#";
            data += isHunting.ToString() + ",";
            data += huntingAreaID + ",";
            data += huntingStartTime.ToString() + ",";
            data += huntingEndTime.ToString();
            //Bank Tabs 15
            data += "#";
            data += GetPlayerBank().GetTabsString();
            data  = Encryptor.EncryptToString(data);
            pos++;
        }
        catch
        {
            data = "Failed to generate save file. Please contact the developer to let him know he messed up. (Error line:" + pos + ")";
        }
        return(data);
    }