示例#1
0
    //Internal call, used by the factory
    private Monster _CreateMonster(string monsterName, Monolith spawningMonolith)
    {
        if (!monsterPrefabDict.ContainsKey(monsterName))
        {
            Debug.LogError("Monster of name: " + monsterName + " not found in monsterDict");
            return(null);
        }

        GameObject newMonsterObj = GameObject.Instantiate(monsterPrefabDict[monsterName]);

        newMonsterObj.name = monsterName; //To remove the (Clone) part
        Monster newMonster = newMonsterObj.GetComponent <Monster>();

        AnimationFactory.Instance.SetupAnimationForMonster(newMonster);


        //Setup the AI
        //Atm there is only one type of AI (State machine), so we will initialize that inside of Monster

        newMonster.Initialize(spawningMonolith);
        if (GV.DEBUG_Monsters_Triggers)
        {
            newMonsterObj.GetComponent <Collider2D>().isTrigger = true;
        }

        return(newMonster);
    }
示例#2
0
 public virtual void Initialize(Monolith _spawningMonolith)
 {
     spawningMonolith = _spawningMonolith;
     bodyInfo.hp      = bodyInfo.maxHp;
     rb = GetComponent <Rigidbody2D>();
     ai = new MonsterAI(this);                   //Atm there is only one kind of AI, so it is just initalized in here
 }
示例#3
0
    public static Monolith SpawnRandomMonolith()
    {
        GameObject monoObj = GameObject.Instantiate <GameObject>(Resources.Load <GameObject>("Prefabs/Monolith/Monolith"));
        Monolith   toRet   = monoObj.GetComponent <Monolith>();

        toRet.Initialize();
        monoObj.transform.position = GV.GetRandomSpotInMap();
        return(toRet);
    }
示例#4
0
    public override void Activate()
    {
        monolith = GetComponent <Monolith>();
        data.inputEvents.WhileDownDelta.AddListener(WhileDown);

        data.inputEvents.OnDown.AddListener(OnDown);
        data.inputEvents.OnUp.AddListener(OnUp);
        data.extraParticles.GetComponent <ExtraParticlesBinder>().Set(GetComponent <ExtraParticlesSetter>());
    }
示例#5
0
        public MonolithCache(Monolith monolith)
        {
            Id               = monolith.Id;
            Position         = monolith.Position;
            WalkablePosition = ExilePather.FastWalkablePositionFor(monolith);
            MonsterName      = monolith.Name;
            MonsterMetadata  = monolith.MonsterTypeMetadata;
            Essences         = monolith.EssenceBaseItemTypes;
            IsValid          = true;

            Log.InfoFormat("[MonolithCache] {0} {1} {2} {3} {4}", Id, WalkablePosition, MonsterName, MonsterMetadata,
                           string.Join(", ", Essences.Select(e => e.Metadata)));
        }
示例#6
0
    public void InitializeExplosion(Vector2 pos, Ingredient ingr)
    {
        //Color the explosion
        SpriteRenderer sr = gameObject.AddComponent <SpriteRenderer>();

        sr.sprite           = Resources.Load <Sprite>("Sprites/PotionSplash");
        sr.color            = ingr.ToColor();
        sr.sortingLayerName = "Potion";

        //Do dmg calcs
        int expLayerMask = LayerMask.GetMask("Monolith", "Monster");  // (1 << LayerMask.NameToLayer("Monolith") | (1 << LayerMask.NameToLayer("Monster")));

        RaycastHit2D[] rhs = Physics2D.CircleCastAll(transform.position, Potion_Explode_Scale_Max, new Vector2(), 0, expLayerMask);
        foreach (RaycastHit2D rh in rhs)
        {
            {
                Monolith m = rh.transform.GetComponent <Monolith>();
                if (m)
                {
                    if (ingr.IngredientsAreSimilar(m.ingredient))
                    {
                        m.DestroyMonolith();
                    }
                }
            }

            {
                Monster m = rh.transform.GetComponent <Monster>();
                if (m)
                {
                    if (ingr.IngredientsAreSimilar(m.ingredientInfo))
                    {
                        m.MonsterDies();
                    }
                }
            }
        }

        //Anim co-routine
        StartCoroutine(UpdateAnim());
    }
示例#7
0
    //Main function used by everyone and by the functions above
    /// <summary>
    /// Creates a monster of given name at the location
    /// </summary>
    public Monster CreateMonster(string monsterName, Vector2 loc, Ingredient monsterIngredient, Monolith creator)
    {
        GameObject toRetObj = null;
        IPoolable  poolable = ObjectPool.Instance.RetrieveFromPool(monsterName); //atm pool is not functional, will always return null

        //toRetObj = GameObject.Instantiate(monsterPrefabDict[monsterName]);

        if (poolable != null)
        {
            toRetObj = poolable.GetGameObject;
        }
        else
        {
            toRetObj = _CreateMonster(monsterName, creator).gameObject;
        }
        Monster toRet = toRetObj.GetComponent <Monster>();

        if (!toRet)
        {
            Debug.LogError("Something went wrong in monster factory, object: " + toRetObj.name + " did not contain a monster script. Returning Null");
        }
        else
        {
            toRet.transform.position = loc;
            MonsterManager.Instance.AddMonster(toRet);
        }
        toRet.InitializeMonsterColor(monsterIngredient);
        return(toRet);
    }
示例#8
0
 public void Update(Monolith monolith)
 {
     // Nothing to do here
 }
示例#9
0
 public override void Initialize(Monolith spawningMonolith)
 {
     base.Initialize(spawningMonolith);
 }